Update_attrbutes without saving?


#1

Hello all,

Is there a method for updating all the attributes from a hash without
saving to the database? (the counterpart of update_attributes but
without saving).

What I want to do is:

person = Person.find(params[:id])
person.update_without_saving(params[:person]) #update the in-memory
object.

Process person object


person.save

I know that when you are creating a new object, you can use Person.new
(updates in memory object) or Person.create (updates and saves to the
database), but don’t know if the second option (apart from
update_attributes that saves to the database) exist when updating.

Thanks in advance,

Ruben

extreme development, S.L.
Paseig del Ferrocarril 335, Planta 3
08860 Castelldefels

Tel. 93 145 87 20
Fax. 93 145 87 21


#2

Rubén Gil wrote:

Hello all,

Is there a method for updating all the attributes from a hash without
saving to the database? (the counterpart of update_attributes but
without saving).

Person.attributes = params[:person]


#3

Lugovoi,

Thanks for your rapid response.

Ruben

extreme development, S.L.
Paseig del Ferrocarril 335, Planta 3
08860 Castelldefels

Tel. 93 145 87 20
Fax. 93 145 87 21

-----Mensaje original-----
De: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] En nombre de Lugovoi
Nikolai
Enviado el: lunes, 19 de diciembre de 2005 14:53
Para: removed_email_address@domain.invalid
Asunto: [Rails] Re: update_attrbutes without saving?

Rubén Gil wrote:

Hello all,

Is there a method for updating all the attributes from a hash without
saving to the database? (the counterpart of update_attributes but
without saving).

Person.attributes = params[:person]


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails