Project must have namespace for Project#find_with_namespace

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-03-14 15:58:10 +02:00
parent 17a9ecf8cf
commit 25f68a71d6
No known key found for this signature in database
GPG key ID: 627C5F589F467F17

View file

@ -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