ruby on rails - Mass change attribute, with check box and a select box -


on index page of users, application lists user's names(string) , if particular user active (boolean). on page able select multiple users, using checkboxes, using select box, select true or false. application should update users checked boolean attribute. how accomplish rails 3? can supply of code if necessary, didn't think didn't explain it's self. thanks.

resources :users   post 'setup', :on => :collection end 

your usercontroller

def setup   @ids = params[:users][:ids]   user.where("id in ? ", @ids).update_all(active: true) end 

supply @users = user.all in view , add following form:

=form_tag setup_users_path   -@users.each |user|     =check_box_tag "users[ids][]", user.id     =user.name   =submit_tag "setup" 

this rough idea of how have done it. wrote away code above without testing in machine; prone errors.

hope helps. :)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -