LOTS of stuff
This commit is contained in:
@@ -2,11 +2,15 @@ class Forumthread < ActiveRecord::Base
|
||||
belongs_to :forum
|
||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
has_many :threadreplies
|
||||
|
||||
attr_accessible :title, :content, :sticky, :locked, :user_author, :user_editor, :forum
|
||||
|
||||
validates_presence_of :title
|
||||
validates_presence_of :title, :author, :forum
|
||||
validates_presence_of :content
|
||||
validates_length_of :content, in: 5..10000
|
||||
|
||||
accepts_nested_attributes_for :threadreplies
|
||||
|
||||
def to_s
|
||||
title
|
||||
@@ -23,4 +27,16 @@ class Forumthread < ActiveRecord::Base
|
||||
def editor
|
||||
@editor ||= user_editor
|
||||
end
|
||||
|
||||
def replies
|
||||
threadreplies
|
||||
end
|
||||
|
||||
def can_read?(user)
|
||||
forum.can_read?(user)
|
||||
end
|
||||
|
||||
def can_write?(user)
|
||||
forum.can_write?(user) && (!locked? || mod?)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user