This, I hope, is a simply answered question.
Based on Agile Web D. with Rails (depot application), I’m
developing a single table application for contact info. There is only
an admin side to this, so there’s always authentication.
Part of the info record (member) is changed_by and changed_at which I
automatically want updated. Changed_at looks after itself (yay!);
however changed_by doesn’t. Since I know who is accessing the table
(everyone has a user_name) I’ve stored user_name in the session. I
can retrieve and display this information to the input form that is
collecting the info, so I know that there is session[:user_name].
Getting it into the active record is more difficult. What I have done
is inside the class for member.rb I’ve added a callback method:
self.changed_by = “Rick”
and this will work. However,
self.changed_by = session[:user_name]
does not, complaining that session is undefined :-(.
Obviously session is not available everywhere. How do I reference the
session correctly from inside the member class?
All flames and grace welcome.