samedi 6 août 2016

`check_box` to pass value to controller action in Rails5

Currently, a button is passing the id of an object to a controller action when clicked.

Now I want to create a checkbox with the same functionality.

Current button code:

<%= link_to "Display", note_display_path(:id => n.id), method: :post, class: 'btn btn-default' %>

Attempted checkbox code:

<%= check_box n, note_display_path(:id => n.id), method: :post %>

This is what I'm trying now, but I'm not seeing any activity in the terminal when clicked.

Its on an index template so there are lots of object being iterated through and displayed, @notes.each do |n|.

But this does not need to be asynchronous; its ok if the page refreshes.

Is this possible?




Aucun commentaire:

Enregistrer un commentaire