On Monday, May 4, 2015 at 8:42:00 AM UTC-7, Jeremy Evans wrote:
>
> On Monday, May 4, 2015 at 12:55:40 AM UTC-7, Tom Close wrote:
>>
>> From the docs: 
>>
>> > Sequel doesn't directly support creating a bunch of associated objects 
>> and delaying saving them to the database until the main object is saved, 
>> like you can with the association.build methods in ActiveRecord. 
>>
>> Is there a reason why sequel doesn't support this? I find myself wanting 
>> to do it relatively often - it's the one thing I miss most from active 
>> record. Is it just a lack of demand for the feature or is it that you 
>> fundamentally believe it should be implemented on a per-project basis? 
>>
>> If I wanted to add this would a plugin be the way to go about it? 
>>
>
> You can fairly easily do it using the instance_hooks plugin. For an 
> example, see how the nested_attributes plugin uses instance_hooks. 
>  Basically, Sequel provides you the tools to easily do it yourself if you 
> need to.
>
> It's possible we could add another plugin that makes it even easier, by 
> making add_* automatically delay if the receiver hasn't been saved.  I'm 
> open to that if people think it would be helpful.  But it's not something 
> we could do by default without merging instance_hooks into the base model 
> plugin.
>

I've added a delay_add_association plugin to Sequel, it will be available 
in the next release: 
https://github.com/jeremyevans/sequel/commit/4a99251287e4d54968de6d55f7f760aa7f621eaa

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/d/optout.

Reply via email to