2014-05-19 15:40:53 +08:00
|
|
|
class RelativeMemoToOpenSourceProject < ActiveRecord::Base
|
|
|
|
# attr_accessible :title, :body
|
2014-05-20 10:06:59 +08:00
|
|
|
belongs_to :open_source_project, :foreign_key => "osp_id"
|
2014-05-20 16:10:05 +08:00
|
|
|
belongs_to :topic, :class_name => 'RelativeMemo', :foreign_key => 'relative_memo_id'
|
2014-05-20 10:06:59 +08:00
|
|
|
|
2014-05-20 16:10:05 +08:00
|
|
|
has_many :no_uses, :as => :no_use, :dependent => :delete_all
|
|
|
|
|
2014-05-20 10:06:59 +08:00
|
|
|
validates_presence_of :osp_id, :relative_memo_id
|
2014-05-20 16:10:05 +08:00
|
|
|
|
|
|
|
scope :no_use_for, lambda { |user_id|
|
|
|
|
{:include => :no_uses,
|
|
|
|
:conditions => ["#{NoUse.table_name}.user_id = ?", user_id] }
|
|
|
|
}
|
2014-05-19 15:40:53 +08:00
|
|
|
end
|