cirandas.net

ref: master

plugins/cms_learning/models/article_resource.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class ArticleResource < ActiveRecord::Base

  attr_accessible *self.column_names
  attr_accessible :article, :resource, :product_category, :person

  belongs_to :article

  belongs_to :resource, polymorphic: true
  belongs_to :product_category, class_name: 'ProductCategory', foreign_key: 'resource_id',
    conditions: ['resource_type = ?', 'ProductCategory']

  belongs_to :person, class_name: 'Person', foreign_key: 'resource_id',
    conditions: ['resource_type = ?', 'Person']

end