Hello all,
my skills in Ruby are very limited so sorry if my questions seem stupid.
I’ve made some searchs on Google and made many tries but I still have
problems. Hope you will able to help me.
Here is the main goals of what I want to do:
I open a page (view).
On this page, some informations are displayed about users.
For each user, I have two check-boxes.
What I want : If a user wants to check / uncheck specific check-box,
send the new “values” to a controller for treatments using a button
(similar to submit_tag).
In my view, I use two check-box tags as following:
<% @users.each do |user| %>
...
<% check_box_tag "scope[]", user.uid, user.in_scope %>
<% check_box_tag "state[]", user.uid, user.in_scope %>
...
<% end %>
Need to precise:
- scope[] and state[] are not “declared” anywhere else than in this
view. I’m expecting to retrieve two lists similar to:
“scope”=> [“uid_1” => “true” (or 1), “uid_2” => “false” (or 0), …]
“state”=> [“uid_1” => “true” (or 1), “uid_2” => “false” (or 0), …]
- user.uid is a specific id for each user,
- user.in_scope is a boolean (true by default).
At the beginning of the view, I also have:
<%= button_to(“Update’ informations”, {:controller => ‘myController’,
:action => ‘myAction’, :id => params[:id]}, class: “myClass”) %>
to make the treatment using a specific controller (“myController”).
In “myController”, I try to retrieve the values of check-boxes using :
list_one = params[:scope]
list_two = params[:stats]
but both list are always equal to ‘nil’.
I’m sure I’m missing some things but I don’t know what.
If you have any solutions, please could you precise:
- If I have to declare specific variables and where,
- If I have to make database migration or something similar (and where),
- If I have to modify my previous code, how (with maximum informations
please).
Any help will be really appreciate!!!
Thank you very much!
Best regards,