I'm trying to figure out how to pass data with ajax using a checkbox in Rails 3.2.11. I have the following line in my view
<%= check_box_tag(
"institution_ids_#{inst.name.gsub(" ", "")}",
inst.id,
false,
data: {
remote: true,
institution_id: inst.id}) %>
When I change the status of the checkbox, I can see that the controller is correctly getting called (specifically the index method of the controller, which is what I want as that is the view I'm in), however, I cannot seem to access the institution_id variable from the params hash on the controller. Can someone please explain how I use ajax to pass data from the view to the controller within a checkbox. I thought the remote: true function would correctly call the controller (which is does) with the additional parameters that I set (which it doesn't).