I have an index page of elements, and I'm trying to implement a "Delete" button that will send a delete request to the controller with a list of the elements user has checked. So far I've done the following
#routes.rb
resources :messages, :except=>[:update,:edit] do
member do
delete :delete_all
end
end
#index.html.haml
=button_to "Delete", {:controller=>"messages", :action => "delete_all"}, :method=>"delete"
...
=check_box "message", "mark"
#messages_controller.rb
def delete_all
....
end
I've been trying to do it RESTfully, but I've come across routing errors and other tricky problems. Like, for instance, when I used pure AJAX I come across the problem with the before_filter that wants to authenticate the user, and it doesn't let my request through.
Can anyone explain to me what I need to do? How do I implement this button?
collection dofor the route, since this is how you use it in your view (without an:id).