Commit 52bd1adb939250bee8b3390f5fafd3d5b5a52ec4

Authored by Braulio Bhavamitra
2 parents a5b68b1c cc833b49

Merge branch 'favorite-has-many' into 'master'

Use has_many through for favorite enterprises

This allow hooks for the joint model in the OpenGraphPlugin

See merge request !382
app/models/enterprise.rb
... ... @@ -19,7 +19,8 @@ class Enterprise < Organization
19 19 has_many :inputs, :through => :products
20 20 has_many :production_costs, :as => :owner
21 21  
22   - has_and_belongs_to_many :fans, :class_name => 'Person', :join_table => 'favorite_enteprises_people'
  22 + has_many :favorite_enterprise_people
  23 + has_many :fans, through: :favorite_enterprise_people, source: :person
23 24  
24 25 def product_categories
25 26 ProductCategory.by_enterprise(self)
... ...
app/models/favorite_enterprise_person.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +class FavoriteEnterprisePerson < ActiveRecord::Base
  2 +
  3 + self.table_name = :favorite_enteprises_people
  4 +
  5 + belongs_to :enterprise
  6 + belongs_to :person
  7 +
  8 +end
... ...