I'd like to display a comparison page so user can compare the properties of several objects in my database. Any number of objects can be compared. I'd also like it to be bookmarkable (so a 'get').
How should I structure my URL / route for the controller?
Something like /foo_compare/1_5_22 where I split the ids into 1, 5 and 22 in the controller?
Maybe /foo_compare/1/5/22, but how would I set up the route?
I'd prefer
/compare?a=1&b=5&c=22
The 1_5_22 is just fugly, and I think that
/compare/1/5/22
is a very non-RESTful route.
# routes.rb
map.connect 'compare/*:comparisons', :controller => 'whatever', :action => 'you_name_it'
# in the controller
ids = params[:comparisons].split('/')
This maps to e.g. /compare/1/5/203.
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