add ability to change namespace from project edit page

This commit is contained in:
Dmitriy Zaporozhets 2012-11-24 22:00:30 +02:00
parent f997947664
commit f37fa968b2
9 changed files with 64 additions and 26 deletions

View file

@ -84,6 +84,16 @@ class Project < ActiveRecord::Base
where("projects.name LIKE :query OR projects.path LIKE :query", query: "%#{query}%")
end
def find_with_namespace(id)
if id.include?("/")
id = id.split("/")
namespace_id = Namespace.find_by_path(id.first).id
where(namespace_id: namespace_id).find_by_path(id.last)
else
find_by_path(id)
end
end
def create_by_user(params, user)
namespace_id = params.delete(:namespace_id)
namespace_id ||= user.namespace.try(:id)