Sha256: 2b13eaaf2484846bf6f4879e28fbe1c432a22d398765e287f3800a14428079b4

Contents?: true

Size: 628 Bytes

Versions: 6

Compression:

Stored size: 628 Bytes

Contents

class OrderObserver < ActiveRecord::Observer
  observe :order

  # Generic transition callback *after* the transition is performed
  def after_transition(record, attribute_name, event_name, from_state, to_state)
    current_user_session = UserSession.activated? ? UserSession.find : nil
    author = current_user_session ? current_user_session.user : record.user
    record.state_events.create({
        :previous_state => from_state,
        :name           => event_name,
        :user_id        => author && author.id 
      })
    ActiveRecord::Base.logger.info("Order##{record.id}: #{from_state} => #{to_state}")
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree-enriquez-0.9.4 app/models/order_observer.rb
spree-0.9.4 app/models/order_observer.rb
spree-0.9.3 app/models/order_observer.rb
spree-0.9.2 app/models/order_observer.rb
spree-0.9.1 app/models/order_observer.rb
spree-0.9.0 app/models/order_observer.rb