Railscasts did a great tutorial on how to do multiple edit from a selection. But I want to build on top of it. What if I want to do more actions (edit and destroy)? This is similar to gmails ability to preform different actions on mail.
I created my form and I have a drop down menu of the action. The form goes to a action in my controller which is supposed to redirect it to the correct action (edit vs destroy). I'm trying to do this with redirect_to and pass my parameters along, but its not working correctly.
def action
if params[:perform_action] == 'edit'
redirect_to :action => 'edit_multiple', :structure_ids => params[:structure_ids]
elsif params[:perform_action] == 'destroy'
redirect_to destroy_multiple_structures_path, :structure_ids => params[:structure_ids]
end
end
But this isn't working properly. My edit_multiple is actually redirected to the show action. Even though I have it set up in my routes and all.
How do I properly pass the parameters on? Or is it a matter of the method its being passed (and if so, how do I change that?) Or what is the proper way to do this (if this isn't it)?
I tired passing params on but that didn't work.
I am using a collection in routes.rb but I can't figure out how to change the redirect_to to be giving a POST. Any ideas?