Ruby on Rails - multiple edit


Ruby on Rails - multiple edit



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?




Rails partial locals not persisting when sent to another partial as its own local

1:



ar-extensions _ne
Ok, so I can't seem to figure out how to get method to change in redirect_to and I can't figure out how to get the params passed correctly.


Ruby on rails: rubygem error
THEREFORE I "cheated" and used jQuery to change the action of the form itself:.
Rails : recognized route
$("#action").change(function(e){     var changeTo = $(e.target);     var value = changeTo.attr("value");     if(value == 'edit'){         $("form").attr("action","/myController/edit_multiple");         $("form").attr("method","POST");     }     if(value == 'destroy'){         $("form").attr("action","/myController/destroy_multiple");         $("form").attr("method","DELETE");      } }); 
Its not optimized but it works.


Bash Command which Rails does Not Find
And action is the id of the select tag.


Patch a Ruby Gem
Hope that helps someone else..
Rails Routing - Not showing an action


Where to put model “utility” functions in Ruby on Rails

2:


FYI- update_all or delete_all is your friend, here..


3:


Gmail-like functionality for delete, archive, etc needs no form, so just create a button or link with the desired functionality.

You only need a form for changing content..



92 out of 100 based on 72 user ratings 1022 reviews

@