socialforge/app/models/forum.rb

18 lines
650 B
Ruby
Raw Normal View History

2013-11-22 10:24:15 +08:00
class Forum < ActiveRecord::Base
2013-11-22 21:55:21 +08:00
include Redmine::SafeAttributes
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL"
has_many :memos, :dependent => :destroy
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
safe_attributes 'name',
'description',
'topic_count',
'memo_count',
'last_memo_id',
'creator_id'
validates_presence_of :name, :creator_id
validates_length_of :name, maximum: 50
validates_length_of :description, maximum: 255
validates :name, :uniqueness => true
2013-11-22 10:24:15 +08:00
end