I am using the Audited gem in my application for tracking user log. Everything is working fine except for current user tracking.
In my case, I have 2 models: Instructor
and Student
. Instructor
will be the current_admin_user
, and I need to find the student manually.
To overcome this issue, I tried to override current_user_method
and create an audited.rb file in the initializers with below content:
Audited.current_user_method = :current_admin_user
This is working fine, but when I use any other method like current_user_or_student
...
Audited.current_user_method = :current_user_or_student
in application_controller.rb
...
def current_user_or_student
current_admin_user || InstructorStudent.find_by_id(id)
end
it is not going into this method, even current_admin_user
is also not storing in audits.
Why isn't my current_user_or_student
method being called when overriding it in application_controller.rb
?