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
Post a Comment