devise add trackable
Step 1: Add the trackable
module to the User
model by opening the app/models/user.rb
file and adding :trackable
to the devise
method.
Step 2: Run the migration generator to add the necessary columns for tracking. Use the command rails generate migration AddTrackableToUsers sign_in_count:integer, current_sign_in_at:datetime, last_sign_in_at:datetime, current_sign_in_ip:string, last_sign_in_ip:string
to create the migration file.
Step 3: Open the newly generated migration file located in the db/migrate
directory and review the columns that will be added to the users
table.
Step 4: Run the migration using the command rails db:migrate
to apply the changes to the database.
Step 5: Restart the Rails server to ensure that the changes take effect by running rails server
in the terminal.
Step 6: Test the functionality of the trackable
module by signing in and out of the application, then checking the sign_in_count
, current_sign_in_at
, last_sign_in_at
, current_sign_in_ip
, and last_sign_in_ip
columns in the users
table to verify that they are being updated accordingly.