Ok,
I have a polymorphic Attachment model which is working okay when it's dependant of a Campaign model. This is working fine:
Campaign.last.attachments
I'm getting all the attachments of that campaign. But, I need to do it the other way around: Retrieve the parent object of an attachment (retrieve the campaign). I imagined it would be something like this.
Attachme开发者_高级运维nt.last.campaign
But I'm getting nil as result. The attachment object has attachable_id: 64, attachable_type: "Campaign".
I'm missing something here but I can't figure it out what.
Thank you!
If you configured the polymorphic association correctly:
some_attachment.attachable
精彩评论