Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove confirmable from Devise (Rails)

I am editing an app that I made few months ago, and I have Devise installed in it with :confirmable enabled. I wanted to remove confirmable from my app, but my db schema already have confirmable built-in many migrations ago, and it is almost impossible to have a smooth rollbacks.

How can I remove confirmable from my app and allow user to sign up right away without having to click on confirmation email link? If it is impossible, is there a workaround?

User model:

class User < ActiveRecord::Base
  attr_accessor :login
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable
  ...

Schema:

  create_table "users", force: :cascade do |t|
    t.string   "email",                  default: "", null: false
    ...
    t.string   "confirmation_token"
    t.datetime "confirmed_at"
    t.datetime "confirmation_sent_at"
    t.string   "unconfirmed_email"
    t.string   "username"
  end

  add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
like image 572
Iggy Avatar asked Jan 06 '23 11:01

Iggy


1 Answers

Just remove confirmable from the parameters to devise method in user.rb

And also remove the columns confirmation_token, confirmed_at, confirmation_sent_at and unconfirmed_email using migrations as they are no longer needed.

like image 160
Arun Kumar Mohan Avatar answered Jan 13 '23 08:01

Arun Kumar Mohan