updated readme

This commit is contained in:
Mike Kelley
2011-08-27 01:41:48 -06:00
commit 17fee3c6d5
98 changed files with 11421 additions and 0 deletions

34
app/models/post.rb Normal file
View File

@@ -0,0 +1,34 @@
class Post < ActiveRecord::Base
# Associations
belongs_to :forum, :counter_cache => true
belongs_to :topic, :counter_cache => true, :touch => true
belongs_to :user, :class_name => "User", :counter_cache => true
# Accessors
attr_accessible :body
# Validations
validates :body, :presence => true
validates :user, :presence => true
# Default Scope
default_scope :order => 'created_at ASC'
# Scope to display only the last n posts. Used for "Recent Posts" display
scope :recent, lambda {
|c| reorder('created_at desc').limit(c)
}
# Callbacks
before_save :topic_locked?
# Methods
private
def topic_locked?
if topic.locked?
errors.add(:base, "That topic is locked")
false
end
end
end