socialforge/app/models/memo.rb

23 lines
541 B
Ruby
Raw Normal View History

2013-11-22 21:55:21 +08:00
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :forums
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
2013-11-23 08:20:03 +08:00
2013-11-22 21:55:21 +08:00
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
2013-11-23 08:20:03 +08:00
def replies
Memo.where("parent_id = ?", id)
end
2013-11-22 21:55:21 +08:00
end