Created
June 3, 2010 01:50
-
-
Save DBA/423315 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
require 'active_record/transitions.rb' | |
class Forum < ActiveRecord::Base | |
include ActiveRecord::Transitions | |
acts_as_nested_set | |
# Associations | |
has_many :posts | |
# Validations | |
validates_presence_of :name, :state | |
state_machine do | |
state :open | |
state :locked | |
state :hidden | |
event :open do | |
transitions :to => :open, :from => [:locked, :hidden] | |
end | |
event :lock do | |
transitions :to => :locked, :from => [:open, :hidden] | |
end | |
event :hidden do | |
transitions :to => :hidden, :from => [:open, :locked] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment