Danimal
2008-Jun-30 04:03 UTC
Manage as a single action in place of new/edit/create/update/show
Hello! Has anyone refactored the REST/CRUD actions into a single "manage" action? I''m finding that often new and edit are so close the it''s awfully non-DRY to have a separate new and edit action. And same with create/update. Also, sometimes, show is just edit without the submit button. I''m wondering if there is a plugin or clean way to do this. Right now, I have the CRUD actions but they all look like: def new render :action => "manage" end def edit @object = Object.find(params[:id]) render :action => "manage" end def create manage end def update manage end And then "manage" as an action handles the create and update actions, looking for a param[:id] to distinguish the two. And the manage view is just the form, which is filled in if the @object exists. What I''d really love is to still have all the REST urls and helpers and such, but have them all direct to a single "manage" action. Has anyone wrestled with this? Any pointers? Thanks! -Danimal --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dhaval Parikh
2008-Jun-30 04:10 UTC
Re: Manage as a single action in place of new/edit/create/up
Hi I guess you are conceptually wrong there is a huge difference in create and edit as well as update... See creating is to create a new record..where as when updating it..ur not inserting all the values..u r just inserting those values that you have changed..So its never advisible to actually pass all the values again.. Also when creating the new record the id which is a primary key is going to get updated..and i think no one wants that to be done..wat u want is that the id of that record remains the same..only the selected value gets updated.. So I guess wat you think is not conceptually proper..Talking abt manage action or url u can set the same url for all action by editing the .htaccess file..but that doesnt mean that the action for all will be manage it will be different action for all the functions.. Hope this is clear to you... Thanks Dhaval Parikh Software Engineer Ruby on Rails http://www.railshouse.com sales(AT)railshouse(DOT)com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---