I need to save all controller notification to database. I create a /config/initializers/notifications.rb
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |name, start, finish, id, payload|
Action.create(
action_type: name,
user: current_user,
data: payload
)
end
but I get error:
undefined local variable or method `current_user' for main:Object
current_user
is a helper it app/helpers/session_helper.rb and it works in entire application.
I need to know user, which made action. How can I call current_user
in this context?