public Method

Base.dup

Duplicate the current resource without saving it.

Examples

my_invoice = Invoice.create(:customer => 'That Company')
next_invoice = my_invoice.dup
next_invoice.new?
# => true

next_invoice.save
next_invoice == my_invoice
# => false (different id attributes)

my_invoice.customer
# => That Company
next_invoice.customer
# => That Company

Source Code

# File active_resource/base.rb, line 626
def dup
  returning self.class.new do |resource|
    resource.attributes     = @attributes
    resource.prefix_options = @prefix_options
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.