diff --git a/app/controllers/enterprise_controller.rb b/app/controllers/enterprise_controller.rb index c53c97e..94e81bd 100644 --- a/app/controllers/enterprise_controller.rb +++ b/app/controllers/enterprise_controller.rb @@ -4,7 +4,7 @@ class EnterpriseController < ApplicationController before_filter :logon def index - @my_enterprises = current_user.person.profiles.select{|p| p.kind_of?(Enterprise)} + @my_enterprises = current_user.person.my_enterprises @enterprises = Enterprise.find(:all) - @my_enterprises end diff --git a/app/models/person.rb b/app/models/person.rb index 347cfc3..5fca50e 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,6 +1,10 @@ class Person < Profile belongs_to :user has_many :affiliations - has_many :profiles, :through => :affiliations + has_many :related_profiles, :class_name => 'Profile', :through => :affiliations has_many :friends, :class_name => 'Person' + + def my_enterprises + related_profiles.select{ |p| p.kind_of?(Enterprise) } + end end -- libgit2 0.21.2