I have three models:
class Product
belongs_to :object, polymorphic: true
belongs_to :membership, foreign_key: :object_id
belongs_to :ticket, foreign_key: :object_id
end
class Membership
end
class Ticket
end
Say, I have a product
that has an associated membership
. E.g. I could do: product.membership
or product.object
But in this case I could also do product.ticket
.
How can I make sure that Rails raises an error in this case?