Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wpeterson/301486 to your computer and use it in GitHub Desktop.
Save wpeterson/301486 to your computer and use it in GitHub Desktop.
class Post < ActiveRecord::Base
validates_presence_of :poster_id, :class_name => "User"
state_machine :type do
state :topic do
validates_presence_of :subject, :forum_id
has_many :posts, :foreign_key => 'topic_id'
end
state :post do
validates_presence_of :topic_id
belongs_to :topic, :class_name => "Post"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment