Reputation: 5288
Im trying to update someone else's Rails app. Right now, an HTML table displays values from a database. What i want is to be able to display a checkbox for each row and on submit, the values of the checkboxes are sent into an array (and the values shouldnt be "checked" or "unchecked", they should be the id's of the database row).
Heres what i have so far.
Checkbox : (message.id being a dynamic id)
<%= check_box_tag "message_ids[]", message.id %>
And on the controller:
@dispatches = Dispatch.find_by_message_ids(CODE TO RETRIEVE CHECKBOX ARRAY GOES HERE)
Any suggestions?
Upvotes: 0
Views: 2699
Reputation: 211590
Check what you receive in your params
because they're probably there if this is defined correctly. The current parameters are always logged in log/development.log
which is something you should have open any time you're debugging something.
Upvotes: 1
Reputation: 239311
Have you tried inspecting the value of params
?
Chances are this will work:
@dispatches = Dispatch.find_by_message_ids(params[:message_ids])
But if it doesn't, just look at what is being sent to your page. Try one of these:
logger.info(params)
or
raise (params.inspect)
or
render :inline => params.to_yaml
Upvotes: 2