Distinguish between invalid username and taken username (fixes #199)
This commit is contained in:
parent
a32d725284
commit
94ff74d09f
@ -12,7 +12,7 @@ class UsernamesController < ApplicationController
|
|||||||
if @user.update(username: params[:user][:username].strip)
|
if @user.update(username: params[:user][:username].strip)
|
||||||
redirect_to_profile(@user)
|
redirect_to_profile(@user)
|
||||||
else
|
else
|
||||||
@invalid_username = true
|
@error = @user.errors[:username].to_s =~ /taken/ ? :username_taken : :username_invalid
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,12 +16,16 @@
|
|||||||
.form-group
|
.form-group
|
||||||
= f.label :username, 'Your username:'
|
= f.label :username, 'Your username:'
|
||||||
= f.text_field :username, class: 'form-control', 'data-behavior' => 'focus'
|
= f.text_field :username, class: 'form-control', 'data-behavior' => 'focus'
|
||||||
- if @invalid_username
|
- if @error == :username_invalid
|
||||||
br
|
br
|
||||||
p.text-danger
|
p.text-danger
|
||||||
' Use only letters, digits and "-" character.
|
' Use only letters, digits and "-" character.
|
||||||
' Examples:
|
' Examples:
|
||||||
em johnny-knoxville, destroyer666
|
em johnny-knoxville, destroyer666
|
||||||
|
- if @error == :username_taken
|
||||||
|
br
|
||||||
|
p.text-danger
|
||||||
|
' This username was already taken.
|
||||||
.form-group
|
.form-group
|
||||||
= f.submit 'Continue', class: 'btn btn-primary'
|
= f.submit 'Continue', class: 'btn btn-primary'
|
||||||
a.btn href=skip_username_path I'll do it later
|
a.btn href=skip_username_path I'll do it later
|
||||||
|
Loading…
Reference in New Issue
Block a user