So, I’m a bit new to rails routing, especially with querystrings.
I’m looking to create a URL that looks like this /dashboard/view_mode/2010/11/18. I also have the need for /dashboard/2010/11/18 and /dashboard/view_mode
Dashboard is a controller, the rest are parameters. I have this relevant lines in my routes.rb
map.connect 'dashboard/:view_mode/:year/:month/:day', :controller => "dashboard", :action => "switch_view"
map.connect 'dashboard/:year/:month/:day', :controller => "dashboard", :action => "index"
map.connect 'dashboard', :controller => "dashboard", :action => "index"
map.connect 'dashboard/:view_mode', :controller => "dashboard", :action => "switch_view"
map.dashboard 'dashboard/:view_mode', :controller => "dashboard", :action => "index"
Where I’m running into an issue is generating this /dashboard/view_mode/2010/11/18 from a starting point of this /dashboard/2010/11/18.
I end up with /dashboard/view_mode/2010/11/18?view_mode=my_view_mode which doesn’t work.
Seems like this should be simply, but … erg, I am just not getting it after trying for awhile.
Thanks.
If anyone comes across this, I ended up moving my view_mode param to the end of the URL (‘dashboard/:year/:month/:day/:view_mode’), which removed the need for another solution, and also seems to make more sense overall anyway 🙂