So I am having trouble figuring out what is going on with a polymorphic assoc/inherited resources, and the documentation is confusing me as I don't know exactly what part of it means -- in the documentation it states:
Right now, Inherited Resources is limited and does not allow you to have two polymorphic associations nested.
But it goes on to show this example.
You can even use it with nested resources:
class CommentsController < InheritedResources::Base
belongs_to :project do
belongs_to :task, :file, :message, :polymorphic => true
end
end
-- My code is similar, but basically, I need projects to be commentable, as well as tasks, which is nested below projects. -- But the code above only semi works if I do the following:
class CommentsController < InheritedResources::Base
belongs_to :project, :polymorphic => true do
belongs_to :task, :polymorphic => true
end
end
But when I do the above, I am still losing methods like parent?, within my project views, which I need to use in order to determine if the resource is a project, or a task, so that I can call the correct params in the form partial (because I have project comment form in one tab, and then a tab for tasks, which is ajax loaded in with a form to comment on that task) --
So I am wondering if what I am doing above is exactly the limitation the documentation is referring to, (but the thing is, when I nest it like above, I am then able to post comments for both projects and tasks, if I dont then I get a could not find polymorphic association error, so it seems like it is sort of working, minus the missing methods), and if that is not the right way to nest this setup, if anyone has any creative workaround ideas.