我试图创建一个自定义帮助这样的:如何通过Rails 3中的“帮手”方法使用自定义助手?
# app/controllers/my_controller.rb
class MyController < ApplicationController
helper :my
def index
puts foo
end
end
# app/helpers/my_helper.rb
module MyHelper
def foo
"Hello"
end
end
但是,我得到了以下错误:
undefined local variable or method `foo' for #<MyController:0x20e01d0>
我缺少什么?
我不知道你能做到这一点......虽然在某些方面,我想我没有现在知道:P(它有很大的潜力被过度使用) – d11wtq 2011-06-02 12:51:42
ahah :)大国有很大的责任;) – apneadiving 2011-06-02 13:04:51