标签: ruby-on-rails
在我的applicatin_controller.rb中,我添加了:
def test? true end
我尝试在我的视图中使用它并且它不起作用
<%=测试? %GT;
错误:
undefined method
答案 0 :(得分:2)
默认情况下,视图中无法访问控制器方法。 请尝试以下方法:
def test? true end helper_method :test?