我缺少聯繫人#顯示前綴'聯繫人',如下所示。Rails - 缺少路由助手前綴
耙路線
contacts GET /contacts(.:format) contacts#index
POST /contacts(.:format) contacts#create
new_contact GET /contacts/new(.:format) contacts#new
edit_contact GET /contacts/:id/edit(.:format) contacts#edit
GET /contacts/:id(.:format) contacts#show
PATCH /contacts/:id(.:format) contacts#update
PUT /contacts/:id(.:format) contacts#update
DELETE /contacts/:id(.:format) contacts#destroy
我想這是點擊以下鏈接時,爲什麼我收到一個點,而不是一個斜槓的原因。
_contact.html.erb
<%= link_to "delete contact", contact, method: :delete,
data: { confirm: "You sure?" } %>
服務器日誌適當DELETE請求,但是,無法呈現正確/聯繫人/ 26的/contact.26代替。
Started DELETE "/contact.26" for 128.177.12.30 at 2016-04-13 21:04:30 +0000
ActionController::RoutingError (No route matches [DELETE] "/contact.26"):
每一個崗位,我遇到了點,而不是一個斜槓似乎從複數錯誤遏制,但是,我不相信這是這裏的情況。此外,我從我的路由文件中刪除了資源:聯繫人,運行$ rake路由,添加資源:聯繫人,運行$ rake路由,問題依然存在。
此問題對於聯繫人模型來說似乎是唯一的,因爲其餘模型在刪除時不會丟失任何前綴或發生此錯誤。
如何將'contact'前綴添加回'contacts#show'?參考
的routes.rb文件:
Rails.application.routes.draw do
root 'static_pages#home'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
get 'contact' => 'static_pages#contact'
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
get 'newevent' => 'events#new'
get 'newteam' => 'teams#new'
get 'newperformance' => 'performances#new'
get 'newhotel' => 'hotels#new'
get 'newcontact' => 'contacts#new'
get 'newflight' => 'flights#new'
get 'newground' => 'grounds#new'
get 'newguest' => 'guests#new'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
resources :users
resources :events
resources :teams do
member do
get :events
end
end
resources :performances
resources :hotels
resources :contacts
resources :flights
resources :grounds
resources :guests
resources :account_activations, only: [:edit]
resources :password_resets, only: [:new, :create, :edit, :update]
end
嘗試'<%= link_to「刪除聯繫人」,contact_path(聯繫人),方法:: delete, data:{confirm:「你確定? }%>' – Abhi
不幸的是,出現相同的路由錯誤。 – ncarroll