Commit 04a4dd140f0a25b4984af813953869d5a7fefeca
1 parent
790354cf
Exists in
master
and in
23 other branches
ActionItem6: trying to make the controller work
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@205 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
app/controllers/enterprise_controller.rb
| ... | ... | @@ -4,7 +4,7 @@ class EnterpriseController < ApplicationController |
| 4 | 4 | before_filter :logon |
| 5 | 5 | |
| 6 | 6 | def index |
| 7 | - @my_enterprises = current_user.person.profiles.select{|p| p.kind_of?(Enterprise)} | |
| 7 | + @my_enterprises = current_user.person.my_enterprises | |
| 8 | 8 | @enterprises = Enterprise.find(:all) - @my_enterprises |
| 9 | 9 | end |
| 10 | 10 | ... | ... |
app/models/person.rb
| 1 | 1 | class Person < Profile |
| 2 | 2 | belongs_to :user |
| 3 | 3 | has_many :affiliations |
| 4 | - has_many :profiles, :through => :affiliations | |
| 4 | + has_many :related_profiles, :class_name => 'Profile', :through => :affiliations | |
| 5 | 5 | has_many :friends, :class_name => 'Person' |
| 6 | + | |
| 7 | + def my_enterprises | |
| 8 | + related_profiles.select{ |p| p.kind_of?(Enterprise) } | |
| 9 | + end | |
| 6 | 10 | end | ... | ... |