Replace

What is the easiest way to replace record in database?

Better that this:

@old = Order.find(5)
@new = Order.find(90)

@old.x = @new.x
@old.y = @new.y
@old.z = @new.z
@old.w = @new.w
@old.p = @new.p
@old.r = @new.r

@old.save

So now @old = @new except @old.id and @old.created_at

On Fri, Mar 6, 2009 at 10:35 AM, Fresh M.
[email protected] wrote:

What is the easiest way to replace record in database?

Better that this:

@old = Order.find(5)
@new = Order.find(90)

@old.x = @new.x
@old.y = @new.y

@old.attributes = @new.attributes

or you can even get rid of @new completely

@old.attributes = Order.find(90).attributes

@old.save