在我的application_helper.rb中,我具有以下内容:
def some_method
do something
end
在我的application_controller.rb中,我具有以下内容:
class ApplicationController < ActionController::Base
include ApplicationHelper
protect_from_forgery with: :exception
require 'json'
require 'csv'
end
在我的data_uploads_controller.rb中,我具有以下内容:
class DataUploadsController < ApplicationController
before_filter :authenticate_user!
before_action :set_data_upload, only: [:show, :destroy]
include DataUploadsHelper
before_filter some_method
但是,我收到错误消息:
undefined local variable or method `some_method' for DataUploadsController:Class\
在application_controller中包含ApplicationHelper会不会意味着ApplicationHelper中声明的方法在所有控制器的范围之内?
您必须将方法作为符号传递:
before_filter :some_method
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句