Topic: Polymorphic association problem
Argh. I hate polymorphic associations. They really make me want to bang my head against something very very hard!
Anyway, here's my question. I have a polymorphic model called Link. It can belong to a Task (as well as other things). My model is set up fine and I'm okay creating a Link that's related to a Task. My problem is, how to I access the Task (or whatever) that the Link is related to. I can't call link.task, right? I thought maybe I could do task = Task.find(link.linkable_id) but that doesn't work either. Pretty much anything I do it complains that "task" is not a valid constant. Of course, even if I can get it working it doesn't solve the fact that I won't normally know whether it's a task or not. I've found lots of blogs that mention polymorphic associations but I haven't found anything that really explains how to use them.