我得到了未初始化的常量DeviseController,我明确要求在Rails项目中使用Devise gem,而不是在application.rb中使用Bundle.require
在application_controller.rb中有以下内容:
SELECT
t.NAME AS TableName,
i.name AS indexName,
SUM(p.rows) AS RowCounts,
SUM(a.total_pages) AS TotalPages,
SUM(a.used_pages) AS UsedPages,
SUM(a.data_pages) AS DataPages,
(SUM(a.total_pages) * 8) / 1024 AS TotalSpaceMB,
(SUM(a.used_pages) * 8) / 1024 AS UsedSpaceMB,
(SUM(a.data_pages) * 8) / 1024 AS DataSpaceMB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME = 'StmALog' AND
i.OBJECT_ID > 255 AND
i.index_id <= 1
GROUP BY
t.NAME, i.object_id, i.index_id, i.name
ORDER BY
OBJECT_NAME(i.object_id)
但是devise_controller吗?调用:: DeviseController,由于某种原因未定义。这是怎么回事?
答案 0 :(得分:3)
在Rails应用程序中使用require
是一个危险信号。除非您在MVC范围之外创建自己的功能(通常将其放置在lib
目录中),否则应很少使用它。
假设您已经安装了devise ...只需删除require
和include
语句...
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
end
如果您有一个名为configure_permitted_parameters
的私有方法,即...(具有适当的自定义属性和操作),一切都会很好
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
end