Adding Username to Sign Up - mmar8/Acebook-Team_404 GitHub Wiki

Adding Username to Sign Up

  1. Type rails generate migration AddUsernameToUsers into the command line this creates the db/migrate ruby file

  2. 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 line add_column :users, :username, :string

  3. 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

  4. Type rake db:migrate into the command line

  5. Now to check the view and the database, in db/schema.rb, the username field