Ruby:如何卸载Devise? [英] Ruby: how to uninstall Devise?
问题描述
我已经安装了 Devise ,现在想删除它,包括它生成的所有文件。我如何做?
I have installed Devise and now want to remove it, including all the files it has generated. How do I do that?
推荐答案
我正在寻找解决今天同样的问题,因为这没有回答,给它一个go =)
I'm looking at solving the same problem today and since this is not answered, giving it a go =)
模型
Devise生成一个用户
模型,如果您默认安装。
删除 devise
下的行。这是我的样子。
Devise generates a User
model if you installed by default.
Remove the lines under devise
. This is how mine looks like.
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
在 attr_accessible
中,您可以删除电子邮件
,:密码
, password_confirmation
和 remember_me
如果您不再需要它们。
In attr_accessible
, you may remove email
, :password
, password_confirmation
and remember_me
if you no longer need them.
视图
默认的Devise安装不会在您的应用程序
文件夹。如果您为Devise生成了覆盖视图,则可以通过运行 rails destroy devise:views
(Rails 3)来删除它们。
A default Devise install doesn't generate views in your app
folder. If you generated overriding views for Devise, you may remove them by running rails destroy devise:views
(Rails 3).
通常,所有视图都存储在 app / views / devise
中。
Generally, all the views are stored in app/views/devise
.
控制器
默认情况下,Devise也不会生成任何控制器。如果你做了任何覆盖,他们很可能被称为 registrations_controller
。在您的项目中搜索继承 Devise :: RegistrationsController
类的控制器。
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 inherit Devise::RegistrationsController
class.
另外,如果您按照Devise的wiki和猴子围绕添加重定向方法等,请查找诸如 after_sign_in_path_for
, store_location
等用于重定向用户。
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_location
etc that are for redirecting users.
迁移
如果您通过其生成器安装了Devise,迁移 create_users
。如果您不需要它,请在迁移中使用 drop_table:users
来摆脱它。
If you installed Devise via its generators, look out for a migration create_users
. If you don't need it anymore, use drop_table :users
in a migration to get rid of it.
我会假设大多数人都想保留他们的用户模型。如果你正在使用Devise< 2.0,迁移由助手完成。从 Gemfile
中删除Devise后,如果您尝试在另一个框中重新运行这些迁移,则Rails将无法理解下面的帮助者并抛出错误。这些帮助者是:
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:
t.database_authenticatable
t.recoverable
t.rememberable
t.trackable
t.encryptable
t.confirmable
t.lockable
t.token_authenticatable # => becomes t.string :authentication_token
对于精确的列,以下是对Devise生成的列的引用。
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
上面的指南列出了Devise使用助手生成的字段。您应该能够查看列表和模型(例如,在控制台中调用 User
),生成一个可移除这些列的迁移。
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 User
in console), generate a migration that removes those columns.
但是...
有一点不幸的是,为了一致性,必须使用上面的指南将迁移转换为不使用助手,然后生成迁移以将其移除。这是为了迁移历史记录的一致性,否则运行迁移的人员可能会尝试调用不存在的助手。此外,您迁移以删除字段也将期望字段存在。
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.
或者,可能是遏制迁移的好时机,并依赖于 schema.rb
/ struct.sql
用于模式的最新状态。即使删除迁移,您也可以随时使用 rake db:schema:load
重新创建开发 DB。
Alternatively, it might be a good time to squash the migrations and rely on schema.rb
/ structure.sql
for the schema's to-date state. Even after deleting migrations, you can always recreate your development DB anytime using rake db:schema:load
.
初始化器和区域设置
删除 devise.rb
配置/初始化器
和 devise.en.yml
在配置/区域设置
。
路线
删除任何 devise_for
行。这些会在删除宝石后引起错误。
Remove any devise_for
lines. These will raise errors after the removal of the gem.
宝石档案
Yaay。所有圆顶,从您的宝石文件中删除 gem'devise'
行。
Yaay. All dome, remove the line gem 'devise'
from your gemfile.
这篇关于Ruby:如何卸载Devise?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!