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 --- app/models/project.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 6425940..7d7edc4 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 -- libgit2 0.21.2