Skip to content

Commit 3606118

Browse files
Allow '.' in username and user routes.
This fixes #102 by changing the constraint on the user resources id to match any character. Expanded the validation on username to allow dots as well.
1 parent 0fa8cc1 commit 3606118

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

app/models/user.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class User
1212
many :questions
1313
many :answers
1414

15-
validates_format_of :username, :with => /^\w+$/,
16-
:message => "Make your username from letters, numbers, and underscores('_')."
15+
validates_format_of :username, :with => /^[\w\.]+$/,
16+
:message => "Make your username from letters, numbers, underscores('_'), and dots('.')."
1717
validates_length_of :username, :in => (1..32),
1818
:message => "Your username needs at least 1 character but no more than 32."
1919

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
get "logout" => "devise/sessions#destroy", :as => "logout"
2929
end
3030

31-
resources :users, :only => :show do
31+
resources :users, :constraints => { :id => /.*/ }, :only => :show do
3232
get "following" => "users#following", :as => :following
3333
get "followers" => "users#followers", :as => :followers
3434
post "follow" => "users#follow", :as => :follow

0 commit comments

Comments
 (0)