On Mar 27, 1:29 pm, trans <[email protected]> wrote:
> Hi--
>
> I have a subclass of Sequel::Model. How do I copy an instance and
> insert the copy into the database as a new record? Can I just use
> 'dup.save' ?

That won't work, because the .dup call would just create a copy of the
record, which would still assumed it has already been saved to the
database.

Assuming the only unique key in the underlying database table is a
field named id, maybe something like:

  # Where m is your model instance
  h = m.values.dup
  h.delete(:id)
  c = Model.create(h)

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to