I have a Ruby on Rails page that loads another page using jquery. I want to pass a parameter “site” to the page via REST, for example:
sitetotals/(site)
instead of the old way with php:
sitetotals?site=(site)
In my routes.rb file I have:
resources :sitetotals
match '/sitetotals', to: 'sitetotals#site'
What’s the best way to do this using Rails? I’m running Rails 3.2.1, and I’m not sure how to pass the parameter to the controller for sitetotals or if that’s even the best practice. Do I put my query in the model or the controller?
Declare your route like this :
In your controller the
siteparameter will be available in theparamshash.See http://guides.rubyonrails.org/routing.html#bound-parameters