I have a situation where I need to do an ajax call and post data to the controller. Since it is a custom submission, the normal params are not accessible to me in the controller. Therefore when I want to save the data I don't have the ids that I want.
my url is like this localhost/events/2/roster/1
I need 2 and 1 in my controller so I can manipulate those records. I considered doing something like a hidden input field on the page with
<%= @event.id %>
<%= @roster.id %>
Then pulling the value into coffeescript but it is making me cringe to do it.
Is there a better way to access this data in the controller?
Can you pass the normal params through ajax to the controller?
thank you for the input.
EDIT Normally when you do a form submit like form_for you get back params which has the data for you including the id of the object. When I do my ajax POST, the id fields are not available to me.
By custom submission I mean its an AJAX post versus a form submit.
EDIT 2 Routes:
resources :events do
resources :rosters
end
post 'rosters/validate'
thanks,