Created
January 4, 2009 19:39
-
-
Save Baael/43160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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