Previous related posts:
By default, the users table in Devise only contains the email and password fields in user profile. Most likely we need to add our custom fields such that we can store more user information. The following steps show you how to add a username field in the users model.
1. Create the username field in the users table
- rails g migration add_username_to_users username:string
2. Apply the new change on database
- rake db:migrate
3. Add the username field to attr_accessible in app/model/user.rb
# Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :username
4. Add the username field to the form inside the following views
... <p><%= f.label :username %><br /> <%= f.text_field :username %></p> ...
You should find the textbox for the username in the above forms now.
Reference: Extend user model with own properties
Update @ 2012-02-13: If you couldn’t find the Devise views files, you need to generate them by the following command.
- rails g devise:views