class IdentitiesController < ApplicationController
def new
@identity = Identity.new
# @identity = env['omniauth.identity']
end
end
我的注册表单是:
=simple_form_for( :identity, url: "/auth/identity/register", :html => { id: :signup_form, class: 'form-horizontal' }) do |f|
= f.error_notification
.form-inputs
.control-group
.controls
.input-prepend
span.add-on
i.icon-user
input#name placeholder="name" type="text" f.name
.control-group
.controls
.input-prepend
span.add-on
i.icon-envelope
input#email placeholder="email" type="text" f.email
.control-group
.controls
.input-prepend
span.add-on
i.icon-key
input#password placeholder="password" type="password"
.control-group
.controls
.input-prepend
span.add-on
i.icon-key
input#password_confirmation placeholder="password confirmation" type="password"
.form-actions
.control-group
.controls
= f.button :submit, :class => 'btn-primary'
我的身份模型
class Identity
include Mongoid::Document
include OmniAuth::Identity::Models::Mongoid
field :name, type: String
field :email, type: String
field :password_digest, type: String
validates_presence_of :name
validates_presence_of :email
validates_uniqueness_of :email
validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
validates_length_of :password, minimum: 8, maximum: 16
end
我使用omniauth-identity gem。我的身份模型、identities_controller 和身份/新视图,如上所示。当我点击注册按钮时,它给出了undefined method 'empty?' for nil:NilClass
错误。我查看了控制台和值帖子。表明
NoMethodError (undefined method `empty?' for nil:NilClass):
omniauth-identity (1.1.0) lib/omniauth/identity/secure_password.rb:71:in `password='
我怎么解决这个问题?我等你的想法。提前致谢。