Given that I have controllers:
app/controllers/app1/users_controller.rb app/controllers/app2/users_controller.rb
I have in my routes file:
["app1", "app2"].each do |n| constraints(:host => "#{n}.com") do scope({:as => vn, :module => vn}) do resources :users end end end
This gives me routes like so:
GET app1_users_path (app1.com/users) { :controller => "app1/users", :action => "index" } GET app2_users_path (app2.com/users) { :controller => "app2/users", :action => "index" }
I do this for every path, for every "app" in my application.
The problem is, as the no. of both apps and paths grows, so does the no. of paths
n = no_of_paths a = no_of_apps (n * a) = "LOADS"
Can anyone think of a way I can set the "module" part of my routes (the controller prefix) as a wildcard so I only have to name each route once?
Something like:
match ":controller/:action(/:id)" => ":host/:controller#:action"
maybe?
/app1/users_controller.rb
is in the same nesting as/app1/sessions_controller.rb
– bodacious Jun 20 '11 at 13:00