communityfeed_item / micropostのコンテンツを削除しようとすると、次のエラーが発生します。
Routing Error
No route matches [GET] "/microposts/45"
Try running rake routes for more information on available routes.
ルートを確認すると、削除と投稿が表示されます。これが実際に機能するために必要なすべてですが、「get」エラーが発生し続けます。
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
locations GET /locations(.:format) locations#index
POST /locations(.:format) locations#create
new_location GET /locations/new(.:format) locations#new
edit_location GET /locations/:id/edit(.:format) locations#edit
location GET /locations/:id(.:format) locations#show
PUT /locations/:id(.:format) locations#update
DELETE /locations/:id(.:format) locations#destroy
communitys GET /communitys(.:format) communitys#index
POST /communitys(.:format) communitys#create
new_community GET /communitys/new(.:format) communitys#new
edit_community GET /communitys/:id/edit(.:format) communitys#edit
community GET /communitys/:id(.:format) communitys#show
PUT /communitys/:id(.:format) communitys#update
DELETE /communitys/:id(.:format) communitys#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
sessions POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
session DELETE /sessions/:id(.:format) sessions#destroy
microposts POST /microposts(.:format) microposts#create
micropost DELETE /microposts/:id(.:format) microposts#destroy
/communitys(.:format) communitys#index
/users(.:format) users#index
profile_info /profile/info(.:format) users#info
join /join(.:format) users#new
login /login(.:format) sessions#new
logout DELETE /logout(.:format) sessions#destroy
root / static_pages#home
help /help(.:format) static_pages#help
about /about(.:format) static_pages#about
contact /contact(.:format) static_pages#contact
/posts(.:format) static_pages#posts
meetups /meetups(.:format) static_pages#meetups
chat /chat(.:format) static_pages#chat
groups /groups(.:format) static_pages#groups
web /web(.:format) static_pages#web
profile /profile(.:format) static_pages#profile
shared / _communityfeed_item.html.erbのビューコードにdeleteメソッドが含まれています:
<% if current_user?(communityfeed_item.user) %>
<%= link_to "delete", communityfeed_item, method: :delete,
confirm: "You sure?",
title: communityfeed_item.content %>
<% end %>
それでも、[削除]をクリックすると、何らかの理由で「取得」リクエストが送信され、ルーティングエラーが発生します。なぜこれが起こっているのか誰かが知っていますか?
この削除リクエストを使用するプロフィールページでも、これは厄介です。
<% if current_user?(micropost.user) %>
<%= link_to "delete", micropost, method: :delete,
confirm: "You sure?",
title: micropost.content %>
<% end %>
まだルート一致がありません[GET]!
さらに奇妙なことに、これはレンダリングされるHTMLです。
<a href="/microposts/48" title="heyheyhye ">delete</a>
<a href="/microposts/47" title="ddsf">delete</a>
これが埋め込まれたルビーであるにもかかわらずなど:
<% if current_user?(communityfeed_item.user) %>
<%= link_to "delete", communityfeed_item, method: :delete,
confirm: "You sure?",
title: communityfeed_item.content %>
<% end %>
ルート.rb内:
Meetumea::Application.routes.draw do
resources :comments
resources :posts
resources :locations
resources :communitys
resources :users
resources :sessions, only: [:new, :create, :destroy]
resources :microposts, only: [:create, :destroy]
match '/communitys', to: "communitys#index"
match '/users', to: "users#index"
match '/profile/info', to: "users#info"
match '/join', to: "users#new"
match '/login', to: 'sessions#new'
match '/logout', to: 'sessions#destroy', via: :delete
root to: "static_pages#home"
match '/help', to: "static_pages#help"
match '/about', to: "static_pages#about"
match '/contact', to: "static_pages#contact"
match '/posts', to: "static_pages#posts"
match '/meetups', to: "static_pages#meetups"
match '/chat', to: "static_pages#chat"
match '/groups', to: "static_pages#groups"
match '/web', to: "static_pages#web"
match '/profile', to: "static_pages#profile"
end