【发布时间】:2018-12-10 13:56:25
【问题描述】:
我正在尝试设置页面标题。我的关注文件夹下有一个 set_title.rb 文件。
module SetTitle
extend ActiveSupport::Concern
included do
before_action:set_name
end
def set_name
if current_user
{
@set_title_name = current_user.name
}
else
{
@set_title_name = "Guest"
}
end
end
这是我的 application_controller.rb 文件
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include DeviseWhitelist
include SetTitle
end
当只有一个 DeviseWhitelist 时,我没有收到任何错误,但是当我尝试添加的关注点多于引发错误时。
错误信息是:
无法自动加载常量 SetTitle,需要 /Users/User/Desktop/Rails/Account/app/controllers/concerns/set_title.rb 来定义它
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5.2