Ok so I have this query in my controlller
@number1 = 3
@number2 = 6
@itemsok = Contribution.where("first_item_id = ?",@number1).where("first_item_grade = ?",@number2)
I have also 2 variables wich should make the query “custom”(not right now)… The question is, how can I save a user input into that variables so it can be “dynamic”…
I think that one approach is to create fom with a button like this:
<%= button_to 'All perfect', contribution_path(:id=> contribution.number1),
:remote => true %>
But how do I listen for this event in Rails?
I am completely lost.
Thank you!
So if I understand your question you would like the user to be able to enter in values to a form that are then used in the controller to perform a search on the data in your database?
If so you should start with a form in your view, something like:
If your routes are set up correctly this will then send the parameters to your controller so you can use them like so: