Colin Law wrote: > On 5 August 2010 12:54, Bla ... <[email protected]> wrote: >> 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
Just a point that I've always found slightly confusing. If I've understood correctly this line.. if @record.update_attributes(params[:sample]) actually *does* the updating part, believe the if is there for error trapping and returning. I've always struggled as to why that line starts with the word "if", am I reading it right in that the line basically does the update_attributes "if" it can? Maybe I'm just thinking about it wrong but it doesn't seem intuitive to me. -- Posted via http://www.ruby-forum.com/. -- 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.

