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.
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
sales(AT)railshouse(DOT)com
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.