0
컨트롤러에 메소드를 추가하고이를 헬퍼 메소드로 선언하는 플러그인을 작성하고 있습니다. 플러그인이 아닌 정적으로 수행 된 경우 다음과 같이 표시됩니다.Rails에서 컨트롤러에 의해 "helper"메소드로 선언 된 메소드를 프로그래밍 방식으로 결정하는 방법은 무엇입니까?
# in RAILS_ROOT/app/controllers/stuffed_animals_controller.rb
class StuffedAnimalsController < ActionController::Base
private
def bear
'Teddy Bear'
end
helper_method :bear
end
# in RAILS_ROOT/app/views/stuffed_animals/index.html.erb:
<%= bear -%>
잘 작동합니다. 나는 :some_helper_method
이 실제로는 도우미 메서드 인 인 것을 테스트하고 싶다.
def test_declared_bear_as_helper_method
assert StuffedAnimalsController.helper_methods.include?(:bear)
end
불행하게도, ActionController::Base
이 :helper_methods
클래스 메소드가 없습니다 :이 시도. 누구든지 클래스가 공개하는 것들의 목록을 어디서 얻을 수 있는지 알고 있습니까? :helper_method
?