Thursday, 19 September 2013

How to fetch id when using dup.update_attributes()

How to fetch id when using dup.update_attributes()

p = product.dup.update_attributes(name: "The latest thing")
The code above creates (and saves) a duplicate of the product object, with
one attribute altered.
How do I retrieve the id of the newly created record? The variable p is
only returning true.

No comments:

Post a Comment