I want all my pages in my 2.3 Rails application to have the url prefixed with:
www.example.com/app/
and I did this writing in routes.rb
the following lines:
# I named the first part of the url ':appl'
map.root :appl => "app", :controller => "home"
# Default routes
map.connect ':appl/:controller/:action/:id'
map.connect ':appl/:controller/:action/:id.:format'
It all works fine, with the exception of map.resources
, where I have
map.resources :pages
and now wherever I have edit_page_path
or page
, the generated url's are not correct, because app
is not inserted at the beginning. I've tried with namespace
and scope
, like I've seen here in chapter 2.6, but with no success.
How should I do this? Is the :appl
in routes a bad idea?
If you are deploying on Passenger, you just need to set (in your webserver config):
RailsBaseURI /app
And then in your app's config:
config.action_controller.relative_url_root = '/app'
You shouldn't need to worry about any sub-uri stuff beyond that. It should Just Work. See the Passenger documentation for more details.
For mongrel, you can use the --prefix option
script/server mongrel -P /app
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With