我試圖創建鏈接的帖子的標題,打開新的頁面與這篇文章。 我試過<%= link_to post.title, posts_path(path) %>
,但得到錯誤鏈接到軌道中的特定頁面
undefined local variable or method `posts_path' for #<#<Class:0x007fbf134f2b88>:0x007fbf13c17d78>
我到底做錯了什麼?
耙:路線:
posts_index GET /posts/index(.:format) posts#index
posts_new GET /posts/new(.:format) posts#new
posts_create POST /posts/create(.:format) posts#create
GET /posts/:id(.:format) posts#show
root / home#index
root / home#index
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
users GET /users(.:format) users#index
user GET /users/:id(.:format) users#show
什麼是你的路由文件看起來像查看rails routing本指南?你可以在你的問題中粘貼「耙路線」的結果嗎? – Mischa
順便說一句,有沒有路線,在路線文件中產生'posts_path'開始... –
有路線帖子和路徑其內置功能 – Avdept