I have a rails app that will show details for a particular project. I am
hoping to make it easy on users by providing subdomains for each project
and specifying the project ID in the routes file as follows -
map.connect ‘:controller/:action/:id’,
:defaults => { :action => ‘list’, :id => nil },
:project_id => 3 # Specify the project ID here.
So once my application gets a request, it has params[:project_id]
defined, that I can use to filter the content made available to users.
This works fine in development and production mode. But functional tests
for controllers don’t like this and barf with - “No route matches” for
any action.
Any thoughts? comments?
The ugly workaround I have is to add this to routes.rb above the above
route -
if ENV[‘RAILS_ENV’] == ‘test’
map.connect “:controller/:action/:id”
end
and call every ‘get’ in functional controller as
get :action, {:project_id => 3}
This works but is Not DRY and Not fun.
What am I missing here?