Create namespace on username init. Raise exception if project cannot be moved

This commit is contained in:
Dmitriy Zaporozhets 2012-11-24 12:25:04 +02:00
parent 4023d9f852
commit d405c8fc60
4 changed files with 21 additions and 8 deletions

View file

@ -12,8 +12,12 @@ class UserObserver < ActiveRecord::Observer
end
def after_save user
if user.username_changed? and user.namespace
user.namespace.update_attributes(path: user.username)
if user.username_changed?
if user.namespace
user.namespace.update_attributes(path: user.username)
else
user.create_namespace!(path: user.username, name: user.name)
end
end
end