Commit cc833b499d5db047ae8012d8b07a038cc3b5fc85

Authored by Braulio Bhavamitra
1 parent 1843b53f

Use has_many through for favorite enterprises

app/models/enterprise.rb
... ... @@ -16,7 +16,8 @@ class Enterprise < Organization
16 16 has_many :inputs, :through => :products
17 17 has_many :production_costs, :as => :owner
18 18  
19   - has_and_belongs_to_many :fans, :class_name => 'Person', :join_table => 'favorite_enteprises_people'
  19 + has_many :favorite_enterprise_people
  20 + has_many :fans, through: :favorite_enterprise_people, source: :person
20 21  
21 22 def product_categories
22 23 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
... ...