【问题标题】:Missing devise routes缺少设计路线
【发布时间】:2017-11-16 19:10:04
【问题描述】:
Rails 5.1
Devise

我的 routes.rb 文件:

Rails.application.routes.draw do

  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  devise_for :users, controllers: {
      sessions: 'users/sessions',
      confirmations: 'users/confirmations',
      passwords: 'users/passwords',
      registrations: 'users/registrations',
      unlocks: 'users/unlocks',
      invitations: 'users/invitations'
  }

  root to: "landings#index"
  resources :users
  resources :followeds
  resources :followers
  resources :locations
  resources :fw_exports

  get 'import_spreadsheet', to: :upload_spreadsheet, controller: 'fw_exports'
  post 'parse_imported_spreadsheet_and_confirm', to: :process_imported_spreadsheet_and_confirm, controller: 'fw_exports'
  post 'process_parsed_spreadsheet', to: :process_parsed_spreadsheet, controller: 'fw_exports'

  scope module: :landings do
    get 'visitors'
  end

end

当我生成路线时,我得到的是:

                            Prefix Verb   URI Pattern                                       Controller#Action
                  new_user_session GET    /users/sign_in(.:format)                          users/sessions#new
                      user_session POST   /users/sign_in(.:format)                          users/sessions#create
              destroy_user_session DELETE /users/sign_out(.:format)                         users/sessions#destroy
                 new_user_password GET    /users/password/new(.:format)                     users/passwords#new
                edit_user_password GET    /users/password/edit(.:format)                    users/passwords#edit
                     user_password PATCH  /users/password(.:format)                         users/passwords#update
                                   PUT    /users/password(.:format)                         users/passwords#update
                                   POST   /users/password(.:format)                         users/passwords#create
          cancel_user_registration GET    /users/cancel(.:format)                           users/registrations#cancel
             new_user_registration GET    /users/sign_up(.:format)                          users/registrations#new
            edit_user_registration GET    /users/edit(.:format)                             users/registrations#edit
                 user_registration PATCH  /users(.:format)                                  users/registrations#update
                                   PUT    /users(.:format)                                  users/registrations#update
                                   DELETE /users(.:format)                                  users/registrations#destroy
                                   POST   /users(.:format)                                  users/registrations#create
            accept_user_invitation GET    /users/invitation/accept(.:format)                users/invitations#edit
            remove_user_invitation GET    /users/invitation/remove(.:format)                users/invitations#destroy
               new_user_invitation GET    /users/invitation/new(.:format)                   users/invitations#new
                   user_invitation PATCH  /users/invitation(.:format)                       users/invitations#update
                                   PUT    /users/invitation(.:format)                       users/invitations#update
                                   POST   /users/invitation(.:format)                       users/invitations#create
                              root GET    /                                                 landings#index
                             users GET    /users(.:format)                                  users#index
                                   POST   /users(.:format)                                  users#create
                          new_user GET    /users/new(.:format)                              users#new
                         edit_user GET    /users/:id/edit(.:format)                         users#edit
                              user GET    /users/:id(.:format)                              users#show
                                   PATCH  /users/:id(.:format)                              users#update
                                   PUT    /users/:id(.:format)                              users#update
                                   DELETE /users/:id(.:format)                              users#destroy
                         followeds GET    /followeds(.:format)                              followeds#index
                                   POST   /followeds(.:format)                              followeds#create
                      new_followed GET    /followeds/new(.:format)                          followeds#new
                     edit_followed GET    /followeds/:id/edit(.:format)                     followeds#edit
                          followed GET    /followeds/:id(.:format)                          followeds#show
                                   PATCH  /followeds/:id(.:format)                          followeds#update
                                   PUT    /followeds/:id(.:format)                          followeds#update
                                   DELETE /followeds/:id(.:format)                          followeds#destroy
                         followers GET    /followers(.:format)                              followers#index
                                   POST   /followers(.:format)                              followers#create
                      new_follower GET    /followers/new(.:format)                          followers#new
                     edit_follower GET    /followers/:id/edit(.:format)                     followers#edit
                          follower GET    /followers/:id(.:format)                          followers#show
                                   PATCH  /followers/:id(.:format)                          followers#update
                                   PUT    /followers/:id(.:format)                          followers#update
                                   DELETE /followers/:id(.:format)                          followers#destroy
                         locations GET    /locations(.:format)                              locations#index
                                   POST   /locations(.:format)                              locations#create
                      new_location GET    /locations/new(.:format)                          locations#new
                     edit_location GET    /locations/:id/edit(.:format)                     locations#edit
                          location GET    /locations/:id(.:format)                          locations#show
                                   PATCH  /locations/:id(.:format)                          locations#update
                                   PUT    /locations/:id(.:format)                          locations#update
                                   DELETE /locations/:id(.:format)                          locations#destroy
                        fw_exports GET    /fw_exports(.:format)                             fw_exports#index
                                   POST   /fw_exports(.:format)                             fw_exports#create
                     new_fw_export GET    /fw_exports/new(.:format)                         fw_exports#new
                    edit_fw_export GET    /fw_exports/:id/edit(.:format)                    fw_exports#edit
                         fw_export GET    /fw_exports/:id(.:format)                         fw_exports#show
                                   PATCH  /fw_exports/:id(.:format)                         fw_exports#update
                                   PUT    /fw_exports/:id(.:format)                         fw_exports#update
                                   DELETE /fw_exports/:id(.:format)                         fw_exports#destroy
                import_spreadsheet GET    /import_spreadsheet(.:format)                     fw_exports#import_spreadsheet
parse_imported_spreadsheet_and_confirm POST   /parse_imported_spreadsheet_and_confirm(.:format) fw_exports#parse_imported_spreadsheet_and_confirm
        process_parsed_spreadsheet POST   /process_parsed_spreadsheet(.:format)             fw_exports#process_parsed_spreadsheet
                          visitors GET    /visitors(.:format)                               landings#visitors

我不应该也获得确认和解锁的路线吗?

【问题讨论】:

  • 我的配置和你几乎一模一样,当我运行 rake 路由时,我得到了相同的行为,但这些路由实际上是有效的。
  • 您是否按照此处的其余步骤操作?:github.com/plataformatec/devise/wiki/…
  • 我没有取消注释 user.rb 中的 :cofirmable, :lockable,我做了,现在我可以看到路线
  • 您不一定需要路线(这就像您的控制器的公共入口)。您可以从内部调用另一个控制器的控制器操作。我没有检查我的路线,但它们可能看起来和你的一样。

标签: ruby-on-rails devise devise-confirmable


【解决方案1】:

问题是你评论了lockable & confirmable。您需要取消注释才能使其正常工作。

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  #   :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :lockable
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-20
    • 1970-01-01
    相关资源
    最近更新 更多