我正在使用rails 4学习ruby,并希望在ActiveSupport中使用关注点。我是这样做的:
# file controllers/concerns/do_things_controller.rb
require 'active_support/concern'
module DoThings
extend ActiveSupport::Concern
def do_something
puts 'something'
end
included do
helper_method :do_something
end
end
# file controllers/application_controller.rb
class ApplicationController < ActionController::Base
require 'concerns/do_things_controller'
include DoThings
end
在 views / layouts / application.html.haml 中,我调用 do_something ,显示错误:
undefined method `do_something'
由于