From 25f68a71d6a176c35e3817cf98d4668a7a303f74 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 14 Mar 2014 15:58:10 +0200 Subject: [PATCH] Project must have namespace for Project#find_with_namespace Signed-off-by: Dmitriy Zaporozhets --- app/models/project.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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 + return nil unless id.include?("/") - where(namespace_id: namespace.id).find_by(path: id.second) - else - where(path: id, namespace_id: nil).last - end + 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