Use Namespace.for_user scope (formerly known as Namespace.root)

This commit is contained in:
Douwe Maan 2017-05-18 08:56:54 -05:00
parent 8d4cc9cbe0
commit 2505fb7b65
2 changed files with 3 additions and 5 deletions

View file

@ -46,7 +46,7 @@ class Namespace < ActiveRecord::Base
before_destroy(prepend: true) { prepare_for_destroy } before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir after_destroy :rm_dir
scope :root, -> { where('type IS NULL') } scope :for_user, -> { where('type IS NULL') }
scope :with_statistics, -> do scope :with_statistics, -> do
joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id') joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id')

View file

@ -350,10 +350,8 @@ class User < ActiveRecord::Base
end end
def find_by_full_path(path, follow_redirects: false) def find_by_full_path(path, follow_redirects: false)
namespace = Namespace.find_by_full_path(path, follow_redirects: follow_redirects) namespace = Namespace.for_user.find_by_full_path(path, follow_redirects: follow_redirects)
return unless namespace && namespace.kind == 'user' namespace&.owner
namespace.owner
end end
def reference_prefix def reference_prefix