On Wednesday, October 9, 2013 12:33:21 PM UTC-7, Adam Gotterer wrote:
>
> Is it possible to add an association without it automatically saving?
>
> x = Something.new
> x.add_someotherclass(...) # saves immediately and sets the association id 
> to nil
>

You can use the instance_hooks plugin to delay adding the associated object 
until after the current object has been saved:

  Something.plugin :instance_hooks
  x = Something.new
  x.after_save{x.add_someotherclass(...)}

The nested_attributes plugin allows for similar things (using the 
instance_hooks plugin internally), but may offer a nicer API.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to