我正在使用公共活动来获取通知。我正在我的祷告模型中跟踪新的祷告。出于某种原因,当我删除 Pain 时 current_user 为零,我不明白为什么。
class Prayer < ApplicationRecord
include PublicActivity::Model
has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy
tracked owner: Proc.new { |controller, model| controller.current_user } #fail current_user is nil
end
class Pain < ApplicationRecord
belongs_to :user
has_many :prayers, dependent: :destroy
end
我可以提供更多代码,但我不确定什么会有用。非常感谢
编辑:我忘了说我正在尝试删除 Rails 管理页面中的疼痛
Edit2:Rails 管理员配置
RailsAdmin.config do |config|
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
show_in_app
end
config.authorize_with do |controller|
redirect_to main_app.root_path unless current_user && current_user.admin
end
end