3/23/2023 0 Comments Rubymine rails console![]() ![]() Go to the migration file in the db/migrate/ directory (mine is called 20220709132706_devise_create_users.rb, but yours will have a slightly different name). We’ll add some tweaks first.Īdd the omniauth module to app/models/user.rb: class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, # for Google OmniAuth :omniauthable, omniauth_providers: end In config/initializers/devise.rb, add the following configuration and pass in your credentials (we will cover obtaining these later on): config.omniauth :google_oauth2, ENV, ENV Set up Devise’s User modelĬreate the User model: $ rails g devise user ![]() Below are my versions running on a MacOS Monterey: $ rails -version & ruby -version Rails 7.0.3 ruby 3.1.2p20 ( revision 4491bb740a) Initial gem installation and configurationĪdd the following gems to your Gemfile: gem "dotenv-rails" gem "devise" gem "omniauth" gem "omniauth-google-oauth2" gem "omniauth-rails_csrf_protection" For example, after you run install Devise, it prompts you to include flash messages in your application layout - I won’t be covering these aspects.Įnsure that you have Rails 7 and the compatible Ruby version installed. It doesn’t cover other good practices along the way. This article covers the minimum needed to install Google SSO with Devise. Follow his account to access his extensive modern Rails resources! ![]() This article is based on his tutorial, with a few tweaks of my own. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |