I have installed Devise and now want to remove it, including all the files it has generated. How do I do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
I’m looking at solving the same problem today and since this is not answered, giving it a go =)
Models
Devise generates a
Usermodel if you installed by default.Remove the lines under
devise. This is how mine looks like.In
attr_accessible, you may removeemail,:password,password_confirmationandremember_meif you no longer need them.Views
A default Devise install doesn’t generate views in your
appfolder. If you generated overriding views for Devise, you may remove them by runningrails destroy devise:views(Rails 3).Generally, all the views are stored in
app/views/devise.Controllers
By default, Devise doesn’t generate any controllers too. If you did any overrides, they are most likely known as
registrations_controller. Search your project for controllers that inheritDevise::RegistrationsControllerclass.Also, if you followed Devise’s wiki and monkey-ed around to add redirect methods etc, look out for methods such as
after_sign_in_path_for,store_locationetc that are for redirecting users.Migrations
If you installed Devise via its generators, look out for a migration
create_users. If you don’t need it anymore, usedrop_table :usersin a migration to get rid of it.I’ll assume most people would want to keep their User model. If you’re using Devise < 2.0, the migrations are done by helpers. Once you remove Devise from the
Gemfile, Rails will not understand the helpers below and throw errors, for instance, when you’re trying to rerun these migrations on another box. These helpers are:For the exact columns, the below is reference to the columns generated by Devise.
https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style
The guide above lists the fields generated by Devise using the helpers. You should be able to look through the list and your model (e.g. calling
Userin console), generate a migration that removes those columns.BUT…
It’s a little unfortunate that for consistency, we have to convert the migration to not use helpers using the guide above then generate a migration to remove them. This is for migration history consistency, otherwise anyone running the migrations might try to call the non-existent helpers. Also, your migration to remove the fields will also expect the fields to be present.
Alternatively, it might be a good time to squash the migrations and rely on
schema.rb/structure.sqlfor the schema’s to-date state. Even after deleting migrations, you can always recreate your development DB anytime usingrake db:schema:load.Initializers and Locale
Remove
devise.rbinconfig/initializersanddevise.en.ymlinconfig/locales.Routes
Remove any
devise_forlines. These will raise errors after the removal of the gem.Gem File
Yaay. All dome, remove the line
gem 'devise'from your gemfile.