开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜