如何禁用rails设备中的电子邮件验证 [英] How to disable email validation in rails device

查看:186
本文介绍了如何禁用rails设备中的电子邮件验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你帮助

尝试: model / user.rb
链接到源

但不起作用

推荐答案

只需注释出指定验证器的电子邮件属性,或完全删除它:

Simply comment out the line specifying validators for the email attribute, or remove it altogether:

# app/models/user.rb
# validates :email, :presence => false, :email => false

您还需要对用户稍微修改表。默认情况下,Devise不允许电子邮件字段为空。创建并运行更改允许电子邮件 null 的迁移。

You'll also need to make a slight modification to your users table. By default, Devise does not allow the email field to be null. Create and run change a migration that allows email to be null.

# in console
rails g migration AddChangeColumnNullToUserEmail

# migration file
class AddChangeColumnNullToUserEmail < ActiveRecord::Migration
    def self.up
        change_column :users, :email, :string, :null => true 
    end

    def self.down
        change_column :users, :email, :string, :null => false 
    end
end

这篇关于如何禁用rails设备中的电子邮件验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆