If you had previously generated your User model with the rails generate draft:devise command here are some steps you should take to resolve
navigate to /git and make a commit.
In the db/migrate/ folder, look for the file with "create_devise_users" in the name and open it.
Replace the change method with the following:
def change
create_table :users do |t|
t.string :username
t.string :password_digest
# ...
# add any addiional columns for your table here
# the syntax is t.column_type :column_name
t.timestamps
end
endYou can add any other columns you had in your table with between the create_table and the first end keyword.
Next, replace the entire content of your user.rb model file with this
class User < ApplicationRecord
endNow open a new terminal and type
rails db:dropthen hit the enter key to remove all the tables in your database.
In the menu dropdown select
rails db:migrateto recreate your tables, including the update User table.
We can follow the same steps we took in photogram-signin from here or copy from the photogram-bootstrap assignment.
-
Create the
users_controller.rband add actions to add theidof the User to thesessionhash when they log in. -
Modify the
application_controller.rbto force a user to sign in to use your app with abefore_action. -
If you force a User to sign_in with a
before_actionmake sure you exclude the actions you wrote to display the sign in form, the sign up form, the add Useridtosessionaction, and the action where you create a User.- something like:
skip_before_action :authenticate_user!, :only => [:session_form, :add_cookie, :registration_form, :create]
- something like:
-
Create a
current_userhelper method in theapplication_controller.rb.
Make a git commit so you never lose any of these changes.
If you need a reminder on any step there is the photogram-signin walkthrough video as a reference and we can also be available to walk you through the changes.




Yeah this looks great