Skip to content

Instantly share code, notes, and snippets.

@Baael
Created January 4, 2009 19:39
Show Gist options
  • Save Baael/43160 to your computer and use it in GitHub Desktop.
Save Baael/43160 to your computer and use it in GitHub Desktop.
class Post < ActiveRecord::Base
cattr_accessor :state_from, :state_to
include ActiveSupport::Callbacks
define_callbacks :after_transition
#kod ....
#(...)
aasm_event :view, :enter => :enter, :exit => :exit, :success => :success do
transitions :to => :read, :from => [:unread]
end
#(...)
def success
callback :after_transition
end
def exit
self.state=self.aasm_state
end
end
class PostObserver < ActiveRecord::Observer
def after_transition(article)
p 'lol'
LOG.warn("after_save #{article.to_yaml}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment