Tag: applicationcontroller

在Rails中从控制器调用helper方法时的“undefined method”

有谁知道我为什么得到 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 最后是ApplicationController 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