Victor Ab
2014-Aug-06 16:02 UTC
Issue in exporting checkbox values (in list) from view to controller
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, -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5a5e310ddebbdf093d7e7df7bd0cfc96%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.