Rails: Copying attributes from an object to another using the "attributes" method

You can select only the attributes that Quote has:

Quote.new(invoice.attributes.select{ |key, _| Quote.attribute_names.include? key })

As noted by @aceofspades (but not with a dynamic solution), you can use ActiveSupport's slice as well:

Quote.new(invoice.attributes.slice(*Quote.attribute_names))

How about the slice method from ActiveSupport?

quote = Quote.new(invoice.attributes.slice(:price, :description))

or even

quote = Quote.new(invoice.attributes.slice(*Quote.accessible_attributes))