Is it possible to invoke a method when the initial state is entered when using the AASM Gem? I'd like the spam_check
method to get called when a comment is submitted, but it doesn't seem to work.
class Comment < ActiveRecord::Base
include AASM
aasm_column :state
aasm_initial_state :submitted
aasm_state :submitted, :enter => :spam_check
aasm_state :approved
aasm_state :rejected
aasm_event :ham do
transitions :to => :approved, :from => [:submitted, :rejected]
end
aasm_event :spam do
transitions :to => :rejected, :from => [:submitted, :approved]
end
def spam_check
# Mark the comment as spam or ham...
end
end