diff --git a/app/models/group.rb b/app/models/group.rb index fc01c4763..4e8f6c12a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -21,7 +21,7 @@ class Group < ActiveRecord::Base scope :search, lambda {|q| where("uname ILIKE ?", "%#{q.strip}%")} scope :opened, where('1=1') scope :by_owner, lambda {|owner| where(:owner_id => owner.id)} - scope :by_admin, lambda {|admin| joins(:relations).where(:'relations.role' => 'admin', :'relations.target_id' => admin.id, :'relations.target_type' => 'User')} + scope :by_admin, lambda {|admin| joins(:objects).where(:'relations.role' => 'admin', :'relations.object_id' => admin.id, :'relations.object_type' => 'User')} attr_accessible :description attr_readonly :own_projects_count @@ -34,7 +34,7 @@ class Group < ActiveRecord::Base # include Modules::Models::Owner def self.can_own_project(user) - (by_owner(user) | by_admin(user)).collect { |el| [el.name, el.id] } + (by_owner(user) | by_admin(user)) end def name diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 4a4ffa06f..6dd8795ed 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -17,7 +17,7 @@ = label_tag t("activerecord.attributes.project.who_owns.group") = radio_button_tag :who_owns, 'group', @who_owns == :group #{}.merge( (@who_owns == :group) ? {:checked => 'checked'} : {} ) -# TODO: Make our own select_box helper with new design, blackjack and bitches! - = select_tag :owner_id, options_for_select( Group.can_own_project(current_user) ) + = select_tag :owner_id, options_from_collection_for_select( Group.can_own_project(current_user), :id, :name ) - else = hidden_field_tag :who_owns, :me .both