我試圖訪問幫助器中控制器中定義的helper_method。這是在軌道2.3我工作。在軌道3/4沒有。那是對的嗎?在幫助器中的控制器中定義的訪問helper_method
application_controller.rb:
class ApplicationController < ActionController::Base
helper_method :some_method
end
application_helper.rb:
module ApplicationHelper
def use_some_method
some_method # trying to use helper_method defined in controller which worked in rails 2.3?
end
end
我得到這個錯誤:
Error: undefined local variable or method `some_method' for...
如果不允許了什麼對 訪問helper_method的方式?
我希望在控制器,視圖和幫助器中可訪問的方法 – Srinivas
我已更新該文章 –
幫助器中的方法可以在控制器中訪問嗎? – Srinivas