So, I am trying to implement a polymorphic association and reviewing the Rails Docs, but am a but confused how they are using "imageable." Is "imageable" some sort of convention or should it really be tied to a table called "imageable"?
imageable is an unwritten naming-convention in Rails polymorphic associations.
Another example is taggable - which refers to an object that can be tagged ie, that is taggable. Or for the imageable example, the object that has an attached image is imageable because it can accept an image.
In this case, you'd have columns on the belongs_to object (Picture) called imageable_id and imageable_type storing the id and model-class of the associated object. You don't need an imageable table... just the columns on the Picture model
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With