Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8442303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:48:58+00:00 2026-06-10T08:48:58+00:00

Rails 3.0.9 Devise 1.5.3 with confirmable I am using Devise and Google OAuth2 authentication.

  • 0

Rails 3.0.9
Devise 1.5.3 with confirmable

I am using Devise and Google OAuth2 authentication.
When Google checked login an pass it returned control to my application.

My problem is: Devise sends a letter with confirmation instructions. But I would like Devise doesn’t send such letters for Google accounts only for users are registered through my application.

User model is:

class User < ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable

    validates_presence_of :user_name, :address, :tel

    # Setup accessible (or protected) attributes for your model
    attr_accessible :user_name, :address, :tel, :attorney_number, :email, :password, :password_confirmation, :remember_me 

    has_many :eclaims
    has_many :createdtemplates

    before_create do |user|
        user.with_agreement = 1
    end

    def self.find_for_google_oauth2(access_token, signed_in_resource=nil)
        data = access_token.info
        user = User.where(:email => data["email"]).first

        unless user
            user = User.create(
                       user_name: 'no defined',
                       address: 'no defined',
                       tel: 'no defined',
                       attorney_number: nil,
                       email: data["email"],
                       encrypted_password: Devise.friendly_token[0,20],
                      )
        end
        user
    end 
end

Users::OmniauthCallbacksController

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
    def google_oauth2
        # You need to implement the method below in your model (e.g. app/models/user.rb)
        @user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)

        if @user.persisted?
          flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
          sign_in_and_redirect @user, :event => :authentication
        else
          session["devise.google_data"] = request.env["omniauth.auth"]
          redirect_to new_user_registration_url
        end
    end 
end

routes.rb:

EFiling2::Application.routes.draw do
  root :to => "home#index"

  devise_for :users, 
    :path_names => { :sign_up => "register", :sign_in => "login", :sign_out => "logout" }, 
    :controllers => { 
      :sessions => "sessions", 
      :registrations => "registrations", 
      :confirmations => "confirmations", 
      :passwords => "passwords",
      :omniauth_callbacks => "users/omniauth_callbacks"
    }
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:49:00+00:00Added an answer on June 10, 2026 at 8:49 am

    Instead of calling create…

    user = User.create(user_name: 'no defined', ...)
    

    build the user object so you can call confirm!…

    user = User.new
    ...
    user.confirm!
    user.save!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a rails application using devise for authentication - including :confirmable functionality.
I currently am using Rails' Devise plugin to handle login/authentication. I am using a
I'm building a Rails application using Devise. Devise is all set up even omniauth.
I recently added devise confirmable module to my rails app. My application runs well
I'm using Rails, Devise, and Omniauth, and I'm trying to login using facebook connect.
I'm trying to implement authentication with Devise in my Rails application (Rails 2.3.8, Devise
I have a rails 3 application that uses Devise and the confirmable module. However,
I am developing a Rails 3 app using the Devise gem for authentication. I'm
I have Devise implemented in a Rails 3 application, with the :registerable and :confirmable
I'm using Rails 3 and Devise 2.0 In the index view of the Posts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.