WikiGardening in progress. We’re combining/reorganizing several related howto’s at the moment, apologies for the dust. Since Rails 0.10 includes Routes, that are meant to replace the use of mod_rewrite and provide more portability across web servers, much of this information is nolonger relevant; the remander is being moved under HowToSetTheBaseURLsOfYourRailsApps.
p{border:1px solid green;padding: 0.5em;}.If you’re using mongrel, you can use the prefix=/subdir in your mongrel startup script, and add ProxyPass /subdir http://localhost:3000/subdir to the Apache configurations.
There seems to be a number of gotchas for running a rails app under a directory i.e. http://www.blah.com/somename/
Please update with the best solutions for these problems. Specifically solutions that allow the directory to a deploy time decision i.e. configuration changes only. If you are using Apache and have access to httpd.conf, you may want to look at HowtoDeployMoreThanOneRailsAppOnOneMachine
in config/routes.rb make sure you prefix all urls with your application path (e.g. somename).
map.connect 'somename/:controller/:action/:id'
hopefully this path can one day be automatically determined, or at least configured in a single place.
Use url_for with a fake controller name, and extra param.
<%= url_for( :controller => "stylesheets", :file => "scaffold.css" ) %>
then in config/routes.rb
map.connect 'somename/stylesheets/:file', :controller => "stylesheets"
Where a suitable one exists, Asset Tags are probably the best way of doing this. For example,
<%= stylesheet_link_tag “scaffold” %>
If the Asset Link Tags don’t recognise your subdirectory, you can add the following to your environment, eg config/environments/production.rb:
ActionController::Base.asset_host = ‘/somename’
WikiGardening in progress. We’re combining/reorganizing several related howto’s at the moment, apologies for the dust. Since Rails 0.10 includes Routes, that are meant to replace the use of mod_rewrite and provide more portability across web servers, much of this information is nolonger relevant; the remander is being moved under HowToSetTheBaseURLsOfYourRailsApps.
p{border:1px solid green;padding: 0.5em;}.If you’re using mongrel, you can use the prefix=/subdir in your mongrel startup script, and add ProxyPass /subdir http://localhost:3000/subdir to the Apache configurations.
There seems to be a number of gotchas for running a rails app under a directory i.e. http://www.blah.com/somename/
Please update with the best solutions for these problems. Specifically solutions that allow the directory to a deploy time decision i.e. configuration changes only. If you are using Apache and have access to httpd.conf, you may want to look at HowtoDeployMoreThanOneRailsAppOnOneMachine
in config/routes.rb make sure you prefix all urls with your application path (e.g. somename).
map.connect 'somename/:controller/:action/:id'
hopefully this path can one day be automatically determined, or at least configured in a single place.
Use url_for with a fake controller name, and extra param.
<%= url_for( :controller => "stylesheets", :file => "scaffold.css" ) %>
then in config/routes.rb
map.connect 'somename/stylesheets/:file', :controller => "stylesheets"
Where a suitable one exists, Asset Tags are probably the best way of doing this. For example,
<%= stylesheet_link_tag “scaffold” %>
If the Asset Link Tags don’t recognise your subdirectory, you can add the following to your environment, eg config/environments/production.rb:
ActionController::Base.asset_host = ‘/somename’