My requirement is to maintain historical data, so basically each
update creates a new record rather than updating the current record.
In order to do this, I fetch the the latest record in the “edit”
action and when the form is submitted I am trying to
redirect_to :action => “create” in the update action.
But for some reason instead it gets redirected to the index action
instead. When I debug, I can see that the form gets submitted to the
“udpate” action but after the redirect_to line, instead of going into
the create action it tries to find some default_renderer…
def update
redirect_to :action => “create”
end
Am I doing this right?
Thanks
On Wed, May 12, 2010 at 6:00 PM, badnaam [email protected] wrote:
def update
redirect_to :action => “create”
end
Am I doing this right?
I’d say no, you’re not.
Keeping back versions of a model should be the responsibility of the
model, not the controller.
You’re still updating the record, the difference is what happens when
you do. The typical way to do this would be to use something like a
before_save callback on the model to save the old version.
You might want to look at something like version_fu
–
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale