diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-14 15:58:10 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-14 15:58:10 +0200 |
commit | 25f68a71d6a176c35e3817cf98d4668a7a303f74 (patch) | |
tree | 09da1b9e0ac8cfe33b001504e515c1abad944d4e | |
parent | 17a9ecf8cf6724613b38c08040bdb786ffe30718 (diff) | |
download | gitlab-ce-25f68a71d6a176c35e3817cf98d4668a7a303f74.tar.gz |
Project must have namespace for Project#find_with_namespace
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/project.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 6425940b21d..7d7edc45739 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -177,15 +177,13 @@ class Project < ActiveRecord::Base end def find_with_namespace(id) - if id.include?("/") - id = id.split("/") - namespace = Namespace.find_by(path: id.first) - return nil unless namespace - - where(namespace_id: namespace.id).find_by(path: id.second) - else - where(path: id, namespace_id: nil).last - end + return nil unless id.include?("/") + + id = id.split("/") + namespace = Namespace.find_by(path: id.first) + return nil unless namespace + + where(namespace_id: namespace.id).find_by(path: id.second) end def visibility_levels |