hello,
I am a Ruby Rails newbie. I am confused as to how to update in a clean way my User table through an admin html view by passing the update parameters for the record.
Ex. I have a User table with the following entries
id integer email string internal boolean admin boolean
I wan to create a view (html) to see all the users an Update their internal and admin status (boolean) via radio buttons. I want to be able to pass the values for each user correctly to the controller Update action.
so I have something like this (pseudo code)
<% form_tag :url => { :action => 'update'} do %>
<% @internal_users.each do |user| %>
<%=h user.email%> <%= radio_button_tag 'user[user.id][internal]' , true, user.internal %> <%= radio_button_tag 'user[user.id][internal]', tru, user.admin %>
<% end %> <%= submit_tag 'Update' %> <% end %
in the controller I defined an Update Action
def update User.update(params[:user].keys, params[:user].values] end
Of course this is not working otherwise I wouldn't asking for help. Can anyone tell me what is the best way to achieve my goal of updating the User internal and admin boolean entries via a html form. Thanks