Hi, I'm looking the best way to log some of save method call. It will be save in another database. I need to log model and its attributes, and user model, which should be somehow taken from session. How to make it Rails Way?
A:
this will write a line like this in your log on every save operation:
#<User id: nil, name: "hi", created_at: nil, updated_at: nil>
in the model:
class User <ActiveRecord::Base
before_save :log_attributes
protected
def log_attributes
logger.info self.inspect
end
end
hellvinz
2010-09-14 09:00:03
But how to attach user from session in this solution?
Sławosz
2010-09-14 10:05:12
I've answered to the "I need to log model and its attributes, and user model" part. The user from session is another thing, it really depends on how you handle your sessions (devise, authlogic, restful_auth...)
hellvinz
2010-09-14 13:31:46
I have authlogic
Sławosz
2010-09-17 12:18:45