没有路由匹配[POST]“ /session.account”

时间:2019-11-21 04:39:18

标签: ruby-on-rails ruby ruby-on-rails-5

嘿,当我尝试使用Devise和Simple_Form登录时,我遇到的问题是 在http://localhost:3000/account/sign_in之后,它将我重定向到http://localhost:3000/session.account,其中弹出错误:没有路由与[POST]“ /session.account”相匹配。  知道为什么吗?以及如何使其恢复工作?

routes.rb

Rails.application.routes.draw do

  get 'tasks/completed', to: 'tasks#completed'
  get 'tasks/pending', to: 'tasks#pending'

  namespace :settings do
  resources :tags
  resources :categories
  end
  resources :settings
  resources :tasks

  devise_for :account

  devise_scope :account do
    get 'removal', to: 'devise/registrations#cancel'
  end

  devise_scope :user do
    delete 'session', to: 'devise/sessions#destroy'
  end

  root to: 'dashboards#index'
end

耙道

                              removal GET    /removal(.:format)                                                                       devise/registrations#cancel
                              session DELETE /session(.:format)                                                                       devise/sessions#destroy
                  new_account_session GET    /account/sign_in(.:format)                                                               devise/sessions#new
                      account_session POST   /account/sign_in(.:format)                                                               devise/sessions#create
              destroy_account_session DELETE /account/sign_out(.:format)                                                              devise/sessions#destroy
                 new_account_password GET    /account/password/new(.:format)                                                          devise/passwords#new
                edit_account_password GET    /account/password/edit(.:format)                                                         devise/passwords#edit
                     account_password PATCH  /account/password(.:format)                                                              devise/passwords#update
                                      PUT    /account/password(.:format)                                                              devise/passwords#update
                                      POST   /account/password(.:format)                                                              devise/passwords#create
          cancel_account_registration GET    /account/cancel(.:format)                                                                devise/registrations#cancel
             new_account_registration GET    /account/sign_up(.:format)                                                               devise/registrations#new
            edit_account_registration GET    /account/edit(.:format)                                                                  devise/registrations#edit
                 account_registration PATCH  /account(.:format)                                                                       devise/registrations#update
                                      PUT    /account(.:format)                                                                       devise/registrations#update
                                      DELETE /account(.:format)                                                                       devise/registrations#destroy
                                      POST   /account(.:format)                                                                       devise/registrations#create   root GET    /                                                                                        

视图/设计/会话/新

<h2>Log in</h2>

<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>

  <div class="form-inputs">
    <%= f.input :email,
                required: false,
                autofocus: true,
                input_html: { autocomplete: "email" } %>
    <%= f.input :password,
                required: false,
                input_html: { autocomplete: "current-password" } %>
    <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Log in" %>
  </div>
<% end %>

<%= render "devise/shared/links" %>

2 个答案:

答案 0 :(得分:0)

使用session_path将匹配要删除的路由,该路由接受'DELETE'方法,这里您需要的是sign_in路径,因此您应该使用

     Loan_ID    Gender  Married Dependents  Education   ApplicantIncome
1   LP001003    Male     Yes        1       Graduate       4583
2   LP001005    Male     Yes        0       Graduate       3000
3   LP001006    Male     Yes        0       Not Graduate   2583
4   LP001008    Male     No         0       Graduate       6000
5   LP001011    Male     Yes        2       Graduate       5417

指向登录路径

答案 1 :(得分:0)

url: session_path(resource_name))中解决的确定问题我更改为url: new_session_path(resource_name)),并且一切正常。