On Wednesday, July 15, 2020 at 6:07:39 AM UTC-7, Petr Kaleta wrote:
>
> Hello,
> please have a look on the following code snippet
>
> class Foo < Sequel:Model
>   one_to_many :bars do |ds|
>     # how can I get here a reference to a current Foo model instance? Or 
> at least current Foo model primary_key
>   end
> end
>
> Btw I am using 
> Sequel::Model.freeze_descendents
>
> Thanks a lot
>

The block is evaluated in the context of the model instance, so self refers 
to the model instance at that point.  Note that relying on that will mean 
that eager loading will not work without a custom :eager_loader option.

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/ba39b9e2-f1fd-45d3-8670-b64643592aa7o%40googlegroups.com.

Reply via email to