解决方法
只需在模型中明确包含帮助器即可
@H_301_12@# app/helpers/adults_helper.rb
module AdultsHelper
def say_hello
"hello,world!"
end
end
# app/models/adult.rb
class Adult < ActiveRecord::Base
include AdultsHelper
end
在控制台中测试
@H_301_12@$script/console >> a = Adult.new # => #<Adult id:...> >> a.say_hello # => "hello,world!"