【发布时间】:2011-01-24 05:46:01
【问题描述】:
有人知道我为什么会得到
undefined method `my_method' for #<MyController:0x1043a7410>
当我从我的 ApplicationController 子类中调用 my_method("string") 时?我的控制器看起来像
class MyController < ApplicationController
def show
@value = my_method(params[:string])
end
end
还有我的助手
module ApplicationHelper
def my_method(string)
return string
end
end
最后是应用控制器
class ApplicationController < ActionController::Base
after_filter :set_content_type
helper :all
helper_method :current_user_session, :current_user
filter_parameter_logging :password
protect_from_forgery # See ActionController::RequestForgeryProtection for details
【问题讨论】:
标签: ruby-on-rails helper helpers applicationcontroller