Sha256: e58da64efdb6a1fb307f538e525ba2685a1f125e54a858eac5c4f8252ae3e7a5
Contents?: true
Size: 798 Bytes
Versions: 13
Compression:
Stored size: 798 Bytes
Contents
class StateMonitor < ActiveRecord::Observer observe :order, :shipment # Generic transition callback *after* the transition is performed def after_transition(object, transition) current_user_session = UserSession.activated? ? UserSession.find : nil if current_user_session author = current_user_session.user elsif object.respond_to?(:user) author = object.user end to_state = transition.attributes[:to_name] object.state_events.create({ :previous_state => transition.attributes[:from], :name => transition.attributes[:event].to_s, :user_id => author && author.id }) ActiveRecord::Base.logger.info("#{object.class}##{object.id}: #{transition.attributes[:from]} => #{transition.attributes[:to]}") end end
Version data entries
13 entries across 13 versions & 2 rubygems