简体   繁体   English

Rails设计删除寄存器

[英]Rails devise delete register

I'm sorry if this is a dumb question. 如果这是一个愚蠢的问题,我很抱歉。 But if i set up devise, how would i completely remove the ability of a user to signup. 但如果我设置了设计,我将如何完全删除用户注册的能力。 I could easily remove the signup views, but what else. 我可以轻松删除注册视图,但还有什么。 Should i add something like devise_for :user, :except => register, or what? 我应该添加像devise_for:user,:except => register,或者什么? The reason im doing this, is because i want the database to be only seeded with users. 我这样做的原因是因为我希望数据库只与用户一起播种。

You are almost right: 你几乎是对的:

devise_for :users, :skip => :registrations

Documentation . 文档

You should have on your models something like this: 你应该在你的模型上有这样的东西:

class User < ActiveRecord::Base
   devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
end

To remove the signup, you should remove the registerable module, so you module should be like this: 要删除注册,您应该删除可注册模块,因此您的模块应该是这样的:

class User < ActiveRecord::Base
   devise :database_authenticatable, :recoverable, :confirmable, :rememberable, :trackable, :validatable
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM