【发布时间】:2012-01-18 10:21:31
【问题描述】:
我从 rails 2.x 迁移到 3.x。现在调用控制器方法时会抛出
undefined method `my_helper_method' for nil:NilClass
MyController.rb
class MyController < ApplicationController
def foo
@template.my_helper_method
end
end
MyControllerHelper.rb
class MyControllerHelper
def my_helper_method
puts "Hello"
end
end
应用控制器
class ApplicationController < ActionController::Base
helper :all
end
如何让它工作?
【问题讨论】:
标签: ruby-on-rails-3 helpers controllers