There is a helper method in the application_controller
:
def current_user
@current_user ||= User.find(session[:user_id])
return @current_user
end
I want to set up before_save
callback in a model - so that the current_user.id
will be saved when the activerecord is updated.
Basically, whenever the model is changed or modified and saved, I want to ensure the updated_by column is populated for that model/
But I'm not sure how to access the current user in the model?
Can anyone advise?