On Wednesday, August 6, 2014 5:27:43 AM UTC-7, Куракин Александр wrote:
>
> I use Sequel and want to try to avoid polymorphism of one_to_many
> association some (maybe strange) way: to use *one_to_many association
> with join table*.
>
> Well I want to have similar to many_to_many association but with one
> parent and ability to destroy (not nullify) children when parent is destroy.
>
> What's the simplest way to do this? Thanx.
>
You can't use a join table with a one_to_many association. Use a
many_to_many association instead. If you want want to destroy children
when the parent is destroyed, maybe something like
class ParentClass < Sequel::Model
many_to_many :children
def before_destroy
cs = children
remove_all_children
cs.each{|c| c.destroy}
super
end
end
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.