On Monday, November 14, 2016 at 11:13:48 PM UTC-8, Satyanarayana Gandham
wrote:
>
> Hi,
>
> I have used CTI in my models. The models are below:
> class Review < Sequel::Model
> plugin :class_table_inheritance, key: :type
> many_to_one :product
> end
>
> class BuyerReview < Review
> many_to_one :buyer
> end
>
> class SellerReview < Review
> many_to_one :seller
> end
>
> class Product < Sequel::Model
> one_to_many :reviews
> one_to_many(:seller_reviews, class: Review) { |ds| ds.where(type:
> "SellerReview") }
> one_to_many(:buyer_reviews, class: Review) { |ds| ds.where(type:
> "BuyerReview") }
> end
>
> How can I write the :seller_reviews and :buyer_reviews associations in the
> Product Model better? Can you please help?
> If I write `one_to_many :seller_reviews`, it is throwing error because it
> is expecting product_id column in the `seller_reviews` table. But the
> column is in reviews table.
>
Try specifying :key=>:reviews__product_id and see if that helps.
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.