module ActiveRecord
class Base
def clone_from(model)
model.attributes.each {|attr, value| eval("self.#{attr}= model.#{attr}")}
end
end
end
# example!
foo = Foo.new
foo.clone_from(Bar.find(:first))
# it works! it's awesome!
|
module ActiveRecord
class Base
def clone_from(model)
model.attributes.each {|attr, value| eval("self.#{attr}= model.#{attr}")}
end
end
end
# example!
foo = Foo.new
foo.clone_from(Bar.find(:first))
# it works! it's awesome!
|