I need to get the current_user id in my model observers: Here is the code for current_user in the lib/authentication.rb file: module Authentication def self.included(controller) controller.send :helper_method, :current_user, :logged_in?, :has_role?, :is_admin? end def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end ... end Here is the propsect_observer.rb file in models directory which needs it: class ProspectObserver < ActiveRecord::Observer def after_update(prospect) prospect.comments.create(:content => @comment_text, :admin_only => @admin_only, :commenter_id => current_user.id) if @comment_text end end current_user is not recognized here. I could include the module in the observer, but that is bad(?). Any suggestion on a good alternative? Thanks for your time. Bharat
on 2009-04-20 18:43
on 2009-04-20 19:42
Forget it. Bad design. I am not pursuing this path anymore.