class Memo < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :forums belongs_to :author, :class_name => "User", :foreign_key => 'author_id' safe_attributes "author_id", "subject", "content", "forum_id", "last_reply_id", "lock", "parent_id", "replies_count", "sticky" validates_presence_of :author_id, :content, :forum_id, :subject validates_length_of :subject, maximum: 50 validates_length_of :content, maximum: 2048 def replies Memo.where("parent_id = ?", id) end def locked? self.lock end def editable_by? user !self.lock end def destroyable_by? user end end