Michael G Michael G - 1 month ago 5x
Ruby Question

Routing rails apps based on uri

I am attempting to migrate two Ruby on Rails apps as they are currently hosted by the original developer who will not allow us access to change the code. The apps are a LocomotiveCMS_Engine and a Spree site. I have them rackup'd just fine running on port 3000 and 3333 respectively.

What I'd like to know is how to make it so that when you go to the page i.e. localhost it will route you to port 3000 and when you go to localhost/store it will route you to port 3333.

I attempted to use this: http://livsey.org/blog/2012/02/23/using-rack-proxy-to-serve-multiple-rails-apps-from-the-same-domain-and-port/ Which works for localhost requests, but when you go to localhost/store the assets of the page don't load correctly so there are no graphics on the page.

I am not extremely familiar with Ruby on Rails so I'm doing my best to piece it together. Any advice would be appreciated!


Your assets don't load correctly because Spree application is generating relative links to your assets, without /store prefix.

You can fix that by changing asset_host config in your Spree aplication. Set this in config/environments/development.rb

config.asset_host = "http://localhost/store"