Project must have namespace for Project#find_with_namespace
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
17a9ecf8cf
commit
25f68a71d6
1 changed files with 6 additions and 8 deletions
|
@ -177,15 +177,13 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_with_namespace(id)
|
def find_with_namespace(id)
|
||||||
if id.include?("/")
|
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)
|
id = id.split("/")
|
||||||
else
|
namespace = Namespace.find_by(path: id.first)
|
||||||
where(path: id, namespace_id: nil).last
|
return nil unless namespace
|
||||||
end
|
|
||||||
|
where(namespace_id: namespace.id).find_by(path: id.second)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visibility_levels
|
def visibility_levels
|
||||||
|
|
Loading…
Reference in a new issue