On Wed, May 12, 2010 at 6:00 PM, badnaam <asitkmis...@gmail.com> wrote:
> 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?

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
http://github.com/jmckible/version_fu


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to