I'm new at ruby on rails and I built a form with a list with checkboxes inside. I asked here how to get the checked values with params and I got it to work. The idea now is to perform some action with the selected items if I click some button, and if I click another one then perform anoother action, but always staying at the same page after postback.
What's happening now, is that I'm getting to the actions, but to another url at the same time. For example:
I've got the following form in my view:
form_tag delete_profiles_path, :method => :put do
submit_tag 'Delete'
@my_announcements.each do |ann|
check_box_tag 'announcement[]', ann.id
end
end
My Profiles controller:
def delete
#some action
end
And routes.rb:
map.resources :profiles, :collection => {:delete => :put}
This will redirect me after submit to:
/profiles/complete, and my form is at /profiles/some id/my-announcements
.
Also, what if I add another button like the Delete one, how can I handle multiple actions when clicking them but staying at the same url?