On 5 August 2010 12:54, Bla ... <[email protected]> wrote:
> I'm in edit page, ok?
>
> I change something and then i submit and update.
>
> What I wanna know is:
>
> How can I return the value that exists BEFORE I update the changes?
> Without losing the changes.
>
>
> Now am I clear?

Much better, though still not sure about what you mean by 'return' the
value that exists...  Where are you returning it from and to?  If you
mean that in the update action of the controller you want to access
the current value of the record in the db before saving the new
values, then, assuming that you are using the normal method like
@record = MyModel.find(params[:id])
 if @record.update_attributes(params[:sample])
Then between those two lines @record has the original values from the
db.  update_attributes picks up the data from params and updates the
db.

Colin

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

Reply via email to