簡體   English   中英

Devise :: Sessions#new中的ActionController :: UrlGenerationError-沒有路由匹配

[英]ActionController::UrlGenerationError in Devise::Sessions#new - No route matches

我正在嘗試找出以下問題。 有人可以在學習Rails的初期幫助我嗎?

環境

紅寶石2.3.3p222(2016-11-21修訂版56859)[i386-mingw32]

Rails 5.1.4

設計(4.3.0)

當前行為

按“注冊”-鏈接后,瀏覽器窗口中將顯示以下結果。

Devise :: Sessions#new中的ActionController :: UrlGenerationError

沒有路線匹配{:action =>“ new”,:controller =>“ devise / flight_records”}

跟隨application.html.erb中的代碼

<%= link_to 'Add New', {:controller => 'flight_records', :action => 'new'} %>
<%= link_to 'Logbook', {:controller => 'flight_records', :action => 'index'} %>
<%= link_to 'Sign Up', new_user_registration_path %>
<%if user_signed_in? %>
  <%= link_to "Sign Out", destroy_user_session_path, method: :delete  %>
<%else %>
  <%= link_to "Log In", new_user_session_path %>
<% end %> 

route.rb中遵循以下代碼

Rails.application.routes.draw do
   devise_for :users
   resources :flight_records 

   #get 'welcome/index'

   root 'flight_records#index'

在耙中遵循以下路線:

耙路

在此處輸入圖片說明

您正在嘗試創建一個新用戶。 因此,應該通過POST操作進入devise#registration。 默認情況下,devise注冊會創建用戶記錄,如果要創建flight_records,請修改表單以指向flight_records創建方法。

現在可以了! application.html.erb的工作版本

| | |
  <%= link_to "Sign Out", destroy_user_session_path, method: :delete %> <%else %> <%= link_to "Log In", new_user_session_path %> <% end %> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM