Commit 25f68a71d6a176c35e3817cf98d4668a7a303f74

Authored by Dmitriy Zaporozhets
1 parent 17a9ecf8

Project must have namespace for Project#find_with_namespace

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 1 changed file with 7 additions and 9 deletions   Show diff stats
app/models/project.rb
@@ -177,15 +177,13 @@ class Project &lt; ActiveRecord::Base @@ -177,15 +177,13 @@ class Project &lt; ActiveRecord::Base
177 end 177 end
178 178
179 def find_with_namespace(id) 179 def find_with_namespace(id)
180 - if id.include?("/")  
181 - id = id.split("/")  
182 - namespace = Namespace.find_by(path: id.first)  
183 - return nil unless namespace  
184 -  
185 - where(namespace_id: namespace.id).find_by(path: id.second)  
186 - else  
187 - where(path: id, namespace_id: nil).last  
188 - end 180 + return nil unless id.include?("/")
  181 +
  182 + id = id.split("/")
  183 + namespace = Namespace.find_by(path: id.first)
  184 + return nil unless namespace
  185 +
  186 + where(namespace_id: namespace.id).find_by(path: id.second)
189 end 187 end
190 188
191 def visibility_levels 189 def visibility_levels