Create namespace on username init. Raise exception if project cannot be moved
This commit is contained in:
parent
4023d9f852
commit
d405c8fc60
4 changed files with 21 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue