Rails 3.2
Devise
devise_security_extensions

我的用户模型包含在其中:

devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable,  :invitable, :confirmable,
     :password_expirable, :password_archivable, :session_limitable, :expirable, :secure_validatable,
     :lockable, :timeoutable

我有一个Admin :: Company :: User控制器,其中包含以下内容:

def create
  params[:user][:additional_location_ids].reject!(&:blank?)
  @user = User.where(email: params[:user][:email]).first
  if @user.nil?
    @user = invite User, params
    if @user.errors.empty?
      @user.create_invitation_message accept_user_invitation_link: accept_invitation_url(@user, invitation_token: @user.invitation_token, type: "user")
      render partial: 'user', locals: { user: @user }
    else
      render partial: 'add_user', locals: { user: @user }
    end
  else
    @user.assign_attributes(params[:user])
    @user.company_profile_users.last.inviter_id = current_user.id
    if @user.save
      company_profile = CompanyProfile.find params[:user][:company_profile_users_attributes]['0'][:company_profile_id]
      company_profile_user = @user.company_profile_users.where(company_profile_id: company_profile.id).first
      @user.create_invitation_for_user_with_company_profile_message(
        company_profile_name: company_profile.name,
        company_name: company_profile.company.try(:name),
        link_view_profiles: info_company_url(company_profile.company),
        link_fill_profile: company_profile_users_url(data_cpu_id: company_profile_user.try(:id))
      )
      render partial: 'user', locals: { user: @user, reload_page: true }
    else
      @company_profile_user = @user.company_profile_users.last
      render partial: 'add_user', locals: { user: @user }
    end
  end
end

和:

def invite resource, params
  resource.invite!( params[:user], current_user ) do |u|
    u.skip_invitation = true
    u.invitation_sent_at = DateTime.now
  end
end

在添加devise_security_extensions之前,代码运行正常 . 添加后,将用户添加到公司停止工作 . 做一些调试,我想到了

@user = invite User, params

失败了 . 通过添加@ user.errors.to_xml,我得到:

<errors>
  <error>Password can't be blank</error>
  <error>Password is too short (minimum is 6 characters)</error>
  <error>Password Your password must be at least 8 characters long, with a minimum of one each: small cap letter (a-z), one capital letter (A-Z), one numeral (0-9) and one special character (eg &amp;%#), and you cannot re-use one of your last 7 password</error>
</errors>

知道怎么处理这个吗?