设计忘记密码没有控制器或错误的参数

时间:2018-07-12 16:26:12

标签: ruby-on-rails devise haml

我正在尝试修复一个损坏的设备,忘记了您的密码链接。我最初没有收到密码控制器错误。此后,我创建了一个从devise继承的密码控制器

class Admin::PasswordsController < Devise::PasswordsController

end

控制器为空,然后定向到共享部分的auth链接

#auth-links
  - if controller_name != 'sessions' && new_session_path
    = link_to "Sign in", new_session_path(resource_name)
    %br/
  / - if devise_mapping.registerable? && controller_name != 'registrations'
  /   = link_to "Sign up", new_registration_path(resource_name)
  /   %br/
  - if devise_mapping.recoverable? && controller_name != 'passwords'
    = link_to "Forgot your password?", new_password_path(resource_name)
    %br/
  - if devise_mapping.confirmable? && controller_name != 'confirmations'
    = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
    %br/
  - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
    = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
    %br/
  - if devise_mapping.omniauthable?
    - resource_class.omniauth_providers.each do |provider|
      = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
      %br/

然后我得到一个错误wrong number of arguments (given 0, expected 1

我觉得我的整个方法都不正确。我相信我不必为了使路由正常工作而创建新的密码控制器。

我的路线

    # Authentication
devise_for :users, controllers: { omniauth_callbacks: 'admin/omniauth_callbacks' }

我的用户模型

 class User < ActiveRecord::Base
 devise :two_factor_authenticatable, :database_authenticatable, 
 :registerable, :recoverable, :rememberable, :trackable, :validatable, 
 :omniauthable, omniauth_providers: [:google_oauth2], stretches: 10

运行耙耙路线时当前的设计路线

admin_user_password POST     /admin/users/password(.:format)                               devise/passwords#create
                    new_admin_user_password GET      /admin/users/password/new(.:format)                           devise/passwords#new
                   edit_admin_user_password GET      /admin/users/password/edit(.:format)                          devise/passwords#edit
                                            PATCH    /admin/users/password(.:format)                               devise/passwords#update
                                            PUT      /admin/users/password(.:format)                               devise/passwords#update
             cancel_admin_user_registration GET      /admin/users/cancel(.:format)                                 devise/registrations#cancel
                    admin_user_registration POST     /admin/users(.:format)                                        devise/registrations#create
                new_admin_user_registration GET      /admin/users/sign_up(.:format)                                devise/registrations#new
               edit_admin_user_registration GET      /admin/users/edit(.:format)                                   devise/registrations#edit
                                            PATCH    /admin/users(.:format)                                        devise/registrations#update
                                            PUT      /admin/users(.:format)                                        devise/registrations#update
                                            DELETE   /admin/users(.:format)                                        devise/registrations#destroy

我非常感谢您提供的所有帮助

0 个答案:

没有答案