想要做一个操作日志记录执行过的操作,
然后想在model里边获取当前操作用户的ID,进行操作的数据表名称,还有操作类型
现在写了一个moduel。
module RecordOperation
extend ActiveSupport::Concern
included do
after_update :record_operation
before_destroy :record_operation
after_create :record_operation
def record_operation
end
end
This is what the design document says
To verify if a user is signed in, use the following helper:
For the current signed-in user, this helper is available:
You can access the session for this scope:
================================
As for the model, a direct way is to directly pass in the user instance or id in the method
I like redmine’s processing method better
User.rb
Then in the login method
Finally User.current can be called anywhere to get an instance of the currently logged in person
In fact, I have not used design in depth, and I am not sure about its specific implementation.
I just got curious, so I will try it when I go back tonight