Here are four errors and how to deal with them when implementing the user management function by Twitter login in Ruby On Rails.
Use the devise gem as the base for user management features. Use the omniauth-twitter gem to create the Twitter login function.
Gemfile
gem 'devise'
gem 'omniauth'
gem 'omniauth-twitter'
bundle install
reference: Send an email when registering with devise Procedure to implement user authentication with Devise + OmniAuth in Rails
NameError in Devise::RegistrationsController#create\_ \_undefined local variable or method \`confirmed\_at' for #User: Did you mean? confirmed?
Add the #confirmable column to the User model
user.rb
devise :confirmable
Missing host to link to! Please provide the :host parameter, set default\_url\_options\[:host\], or set :only\_path to true\_
Specify the host url in config> environment> development.rb
/config/environments/development.rb
host = 'samplehost'
Rails.application.routes.default_url_options[:host] = host
Reference: When Missing host to link to! Appears in Rails. Settings when assembling URLs in model
This is an error due to the user information not being registered in the DB.
1 is recommended.
undefined method \`id' for nil:NilClass
Error cause: You cannot log in and your user ID is null. Reference: undefined method ʻid'for nil: About NilClass
Check if current_user has a value
Recommended Posts