Topic: DRY. How could i improve this ? (model+session)
Dear Rails Gods
Ive recently added versioning to a bunch of Models via the handy Vestal Versions gem.
In each of my models I've added a 'author' field which is the user_id of the person who is making the change to whatever model.
We grab this user id from the session where it has been stored previously.
currently, every time a versioned model is edited, we save who is doing the editing (the user) as the 'author'
Now when i first built this i thought i could simply do a before_save in the model and set the record's author there but i've since learnt i cannot access the session from the model so that killed that idea.
what i ended up doing was creating an method in the Application controller which returns the current user's ID and then i call that method from various Controller methods when creating / updating any of my versioned models..
This is all working fine, but i suspect it could be improved and id like to do so..