# Manage as a single action in place of new/edit/create/update/show

**URL:** <https://www.ruby-forum.com/t/manage-as-a-single-action-in-place-of-new-edit-create-update-show/141724>\
**Category:** Rails\
**Created:** [June 30, 2008, 6:04am UTC](https://www.ruby-forum.com/t/manage-as-a-single-action-in-place-of-new-edit-create-update-show/141724 "2008-06-30T06:04:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [June 30, 2008, 6:04am UTC](https://www.ruby-forum.com/t/manage-as-a-single-action-in-place-of-new-edit-create-update-show/141724/1 "2008-06-30T06:04:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [June 30, 2008, 6:10am UTC](https://www.ruby-forum.com/t/manage-as-a-single-action-in-place-of-new-edit-create-update-show/141724/2 "2008-06-30T06:10:00Z")

</div>

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 P.  
Software Engineer  
Ruby on Rails

> **[RailsHouse : Ruby on Rails Development & Consulting, Waterloo, Canada](https://railshouse.com)**
>
> RailsHouse is Waterloo, Ontario based Ruby on Rails Consultancy firm which provides RoR Development, Migration, Staffing, Maintenace and Support Services

sales(AT)railshouse(DOT)com
