Thanks! But what should custom one_to_one looks like?
суббота, 4 мая 2019 г., 19:44:04 UTC+3 пользователь Jeremy Evans написал: > > On Saturday, May 4, 2019 at 12:39:58 AM UTC-7, [email protected] > <javascript:> wrote: >> >> Good day! >> >> I'm maintainer of sequel_polymorphic gem >> <https://github.com/jackdempsey/sequel_polymorphic>. (Note: didn't use >> it and Sequel for a long time so could forget something.) I'm investigating >> this >> issue <https://github.com/jackdempsey/sequel_polymorphic/issues/32> now >> (or this <https://github.com/jeremyevans/sequel/issues/1617>). >> >> We have a custom setter >> <https://github.com/jackdempsey/sequel_polymorphic/blob/v0.5.0/lib/sequel/plugins/polymorphic.rb#L163-L166> >> >> for our custom one-to-one association >> <https://github.com/jackdempsey/sequel_polymorphic/blob/v0.5.0/lib/sequel/plugins/polymorphic.rb#L149>. >> >> We took that setter from here >> <https://sequel.jeremyevans.net/rdoc/files/doc/advanced_associations_rdoc.html#label-Polymorphic+Associations> >> . >> >> And mentioned issue disappears if I drop custom setter (or set to nil). >> >> 1. But if custom setter is not set (for one-to-one association) - is this >> method >> <https://github.com/jeremyevans/sequel/blob/5.20.0/lib/sequel/model/associations.rb#L2213-L2239> >> used? >> 2. If custom setter is set - is method from p.1 called? >> >> If answers are [true, false] I have a new question: >> >> 3. Have we to do something else on our setter. Since default setter >> <https://github.com/jeremyevans/sequel/blob/5.20.0/lib/sequel/model/associations.rb#L2213-L2239> >> does >> much more then guide example's method >> <https://sequel.jeremyevans.net/rdoc/files/doc/advanced_associations_rdoc.html#label-Polymorphic+Associations> >> . >> > > Yes, you need to modify your setter to actually save the object. It > should also unset the values for any currently associated object. > > The guide example you linked to is for many_to_one, not one_to_one. It > looks like you copied your setter from many_to_one to one_to_one, which is > wrong. > > 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 https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
