I know, it is against the MVC to speak directly to a session object in
the model but I am looking for a solution to this problem with auditing
I have a SystemLog model which works as a sort of auditor to track
changes. It has a user_id that references the user that initiated the
change and a text string with a description and some other columns.
Whenever I save a model, i want to create a SystemLog object with values
I can get from the model that is being saved itself, except for the
How am I supposed to get the session[:user] data neatly to the model the
way Ruby wants it to? Or is there any other way to realise this auditing
process which I am overlooking?
The alternative violates the DRY philosophy. After every call to
@object.save in the controller I manually create a new SystemLog object
with the @object’s attributes and session[:user] variable.