Created
January 19, 2011 11:56
-
-
Save lucasrenan/786065 to your computer and use it in GitHub Desktop.
QuestionAnswer - Devoltapracasa
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 QuestionAnswer | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
include Stateflow | |
field :question | |
field :answer | |
field :complement | |
field :state | |
embeds_one :reader | |
references_one :expert | |
validates :question, :presence => true | |
accepts_nested_attributes_for :reader | |
stateflow do | |
state_column :state | |
initial "aguardando triagem" | |
state "aguardando triagem" | |
# state :enviada do | |
# enter do |obj| | |
# obj.generate_token! | |
# QuestionMailer.send_to_expert(obj).deliver | |
# end | |
# end | |
# state :respondida do | |
# exit do |obj| | |
# #QuestionMailer.send_to_admin(obj).deliver | |
# end | |
# end | |
# state :aprovada | |
event :enviar do | |
transitions :from => :nova, :to => :enviada | |
end | |
# event :responder do | |
# transitions :from => :enviada, :to => :respondida | |
# end | |
# | |
# event :aprovar do | |
# transitions :from => :respondida, :to => :aprovada | |
# end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment