0
Rails的可用:url_for可用在一個單獨的類必須被實例化:的Rails:url_for在一個獨立的類必須被實例化
class ProfilePresenter < ActionController::Base
attr_reader :profile
def initialize(profile)
super
@a = url_for(:controller => 'profiles', :action => 'view', :profile_url => 'dd')
@a
@profile = profile
end
end
如何使url_for工作? 我試圖延長的ActionController ::基地和::的ActionView基地,我不能:■
這個類如何被實例化?如果它不是正常控制器流程的一部分,則需要手動構建請求上下文。 – 2010-05-15 01:23:11
在模型中有這樣的方法: ProfilePresenter.new(self) – 2010-05-15 11:05:21