diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-15 06:27:15 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-15 06:27:15 +0000 |
commit | 66a484c9cdb6b35801aa09a95e7295043e0d52ac (patch) | |
tree | e42a5f39bc1977ddcc04e388e9d3f46b66d54b87 /app | |
parent | 7c5320d2c8997208cdc551f53575f99dc163e674 (diff) | |
parent | a9f2903e8642bc15da5a0b53f71b65ec1f25fc6e (diff) | |
download | gitlab-ce-66a484c9cdb6b35801aa09a95e7295043e0d52ac.tar.gz |
Merge branch 'improve-project-lookup' into 'master'
Improve Project Lookup
Fixes #1080
Diffstat (limited to 'app')
-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 |