레일을 인스턴스화해야하는 고립 된 클래스에서 사용할 수 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 작업을 할 : url_for가 인스턴스화되어야하는 절연 클래스에서 사용할 수? 내가는 ActionController :: 자료와 ActionView :: Base를 확장하기 위해 노력하고 내가 캔트 :의 당신이 포함한다고 생각
이 클래스는 어떻게 인스턴스화됩니까? 이것이 정상적인 컨트롤러 흐름의 일부가 아닌 경우 수동으로 요청 컨텍스트를 작성해야합니다. –
모델에는 다음과 같은 방법이 있습니다. ProfilePresenter.new (self) –