From 04a4dd140f0a25b4984af813953869d5a7fefeca Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 27 Jul 2007 21:37:15 +0000 Subject: [PATCH] ActionItem6: trying to make the controller work --- app/controllers/enterprise_controller.rb | 2 +- app/models/person.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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