Adding Username to Sign Up - mmar8/Acebook-Team_404 GitHub Wiki
Adding Username to Sign Up
-
Type
rails generate migration AddUsernameToUsers
into the command line this creates the db/migrate ruby file -
In the migrate file is a class called AddUsernameToUsers with a blank method called
change
in it. We have to modify this file to add a column to the table users, with the name username and of type string we add the lineadd_column :users, :username, :string
-
Then we add the line
add_index :users, :username, unique: true
This ensures that the username is unique and an index so that the table can be searched on the user name -
Type
rake db:migrate
into the command line -
Now to check the view and the database, in db/schema.rb, the username field