Ruby on rails Rails-缺少路由帮助器前缀
我缺少联系人#显示前缀“contact”,如下所示 耙道Ruby on rails Rails-缺少路由帮助器前缀,ruby-on-rails,ruby,routes,Ruby On Rails,Ruby,Routes,我缺少联系人#显示前缀“contact”,如下所示 耙道 contacts GET /contacts(.:format) contacts#index POST /contacts(.:format) contacts#create new_contact GET /contacts/new(.:f
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?" } %>
我遇到的每一篇文章都是一个点而不是斜线,这似乎都源于一个复数错误,然而,我不相信这里的情况是这样的
此外,我已经从我的路由文件中删除了资源:联系人,运行$rake路由,添加了资源:联系人,运行$rake路由,问题仍然存在
这个问题似乎是contacts模型独有的,因为我的其他模型在删除时没有丢失任何前缀或出现此错误
如何将“联系人”前缀添加回“联系人#显示”
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
设置的路由之间可能存在冲突
resources :contacts
及
最简单的解决方案可能是更改静态页面的链接。如果可以的话,最好将资源放在一起。我刚刚遇到了同样的错误 解决我的问题的办法是在资源的末尾 我有“资源”,和你有同样的问题 我把它改成了“资源”,它解决了我的问题
就我而言,这只是一个打字错误。昨天我发现了这个错误。修正的是删除未被使用的帮助文件。可能值得您一试。很遗憾,请尝试
相同的路由错误。
resources :contacts
get 'contact' => 'static_pages#contact'