class ProfilePresenter< ActionView :: Base | url_for不起作用。为什么?

时间:2010-05-28 20:00:43

标签: ruby-on-rails url-for

class ProfilePresenter < ActionView::Base 
 def initialize
  super
  url_for   # i got: You have a nil object when you didn't expect it!
            #        The error occurred while evaluating nil.url_for
 end
end

url_for不起作用。为什么呢?

我创建了一个像这样的新实例

ProfilePresenter.new

1 个答案:

答案 0 :(得分:1)

已解决:我需要在实例化ActionView :: Base

时传递控制器实例