开发者

Polymorphic Association / Rails3 Question

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜