Ruby on rails 忘记密码时:发生此错误";电子邮件可以';“不要空白”;

Ruby on rails 忘记密码时:发生此错误";电子邮件可以';“不要空白”;,ruby-on-rails,ruby,ruby-on-rails-4,devise,Ruby On Rails,Ruby,Ruby On Rails 4,Devise,我在忘记密码时遇到这个错误。如何修复它。我想定制它。我需要通过电子邮件以及用户名重置密码。 我的模型如下 class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable belongs_to :role devise :database_authen

我在
忘记密码时遇到这个错误。
如何修复它。我想定制它。我需要通过
电子邮件
以及
用户名
重置密码。 我的模型如下

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  belongs_to :role
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :confirmable, :lockable, :validatable, :authentication_keys => [:login]
  # validates_uniqueness_of :username
  # validates_presence_of   :username

  after_create :create_profile



  attr_accessor :login

  def create_profile
    if self.role.name == "student"
        Student.create :user_id => self.id
      elsif self.role.name == "company"
        Company.create :user_id => self.id
      else
        University.create :user_id => self.id  
    end    
  end

  def self.find_for_database_authentication(warden_conditions)
    conditions = warden_conditions.dup
    if login = conditions.delete(:login)
      where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
    else
      where(conditions).first
    end
  end

end
class用户[:登录]
#验证用户名的唯一性
#验证是否存在:用户名
创建后:创建配置文件
属性访问器:登录
def创建_配置文件
如果self.role.name==“学生”
Student.create:user\u id=>self.id
elsif self.role.name==“公司”
Company.create:user\u id=>self.id
其他的
University.create:user_id=>self.id
结束
结束
定义self.find_用于_数据库_身份验证(典狱长条件)
条件=典狱长_conditions.dup
如果login=conditions.delete(:login)
where(条件)。where([“lower(username)=:value或lower(email)=:value”,{:value=>login.downcase}])
其他的
在哪里(条件)。首先
结束
结束
结束

这1个错误是什么?我们应该猜猜看吗?@rustam------现在检查一下,谢谢你提到它。相关代码丢失了-控制器代码是什么?您是否试图在不输入电子邮件的情况下保存用户?电子邮件字段是强制性的吗?也许可以阅读一些文档并得出一些想法