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