Inherited Resources: can't get the parent in a polymorphic_belongs_to
I am using Inherited Resources in my Rails application but I have an issue:
开发者_StackOverflow中文版I can't access the parent object when I use a polymorphic relation between my controllers.
Following the documentation, I have a controller like this:
class PhotosController < InheritedResources::Base
belongs_to :user, :task, :polymorphic => true
def index
logger.debug(parent.inspect)
end
end
But parent always returns nil. It doesn't work either with:
polymorphic_belongs_to :user, :task
However, it works if I don't use a polymorphic relation:
belongs_to :user
or
belongs_to :task
Note that my routes and everything else regarding inherited_resources work fine.
I am using Rails 2.3.10 and InheritedResources 1.0.6 but some people have the same issue with Rails 3. Here is a post in the mailing list: http://groups.google.com/group/inherited_resources/browse_thread/thread/8d154492bad90f2d
Any idea?
Thank you
精彩评论