Commit 1f71e6736b26f5715246c12294ea931a1c690b48
1 parent
39655247
Exists in
master
and in
29 other branches
ActionItem6: some enterprise level fixes :)
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@185 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
5 additions
and
2 deletions
Show diff stats
app/controllers/enterprise_controller.rb
... | ... | @@ -2,7 +2,8 @@ |
2 | 2 | class EnterpriseController < ApplicationController |
3 | 3 | |
4 | 4 | def index |
5 | - @my_enterprises = current_user.enterprises | |
5 | + @my_enterprises = current_user.enterprises if current_user | |
6 | + @enterprises = Enterprise.find(:all) - @my_enterprises | |
6 | 7 | end |
7 | 8 | |
8 | 9 | def register |
... | ... | @@ -21,6 +22,7 @@ class EnterpriseController < ApplicationController |
21 | 22 | |
22 | 23 | def create |
23 | 24 | @enterprise = Enterprise.new(params[:enterprise]) |
25 | + @enterprise.manager = current_user | |
24 | 26 | if @enterprise.save |
25 | 27 | flash[:notice] = _('Enterprise was succesfully created') |
26 | 28 | redirect_to :action => 'register' | ... | ... |
app/models/enterprise.rb
app/models/user.rb
... | ... | @@ -10,7 +10,7 @@ class User < ActiveRecord::Base |
10 | 10 | |
11 | 11 | has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner |
12 | 12 | has_many :affiliations |
13 | - has_many :enterprises, :through => :affiliation | |
13 | + has_many :enterprises, :through => :affiliations | |
14 | 14 | # Virtual attribute for the unencrypted password |
15 | 15 | attr_accessor :password |
16 | 16 | ... | ... |