私はウェブサイトから製品を掻き集め、自分のDBに挿入しました。すべての製品が[表示]ページに正しく表示されていますが、削除ボタンが機能しないようです。ルートの一番上に、それはしなかった:リピートは私のすくいルートである理由は、私が最初に手動でルートを書きましたが、その後、私はちょうど「ibottaリソースを」移動しようとした個々のデータを削除するボタン。
resources :ibotta
を使用したことです作業。私は「破棄」ボタンをクリックすると、それは私を取るのリンクは
「https://rails-tutorial2-chriscma.c9users.io/ibotta.14738」すべてのヘルプははるかに高く評価されて
、おかげでします。
ビューコントローラで
<h1>Show Page for iBotta</h1>
<h3><%= @products.length %> products in the iBotta DB</h3>
<% @products.each do |x| %>
<p>Title: <a href=<%=x.link%>><%= x.title %></a> </p>
<p>Value: <%= x.values %> </p>
<p>Store: <%= x.store %> </p>
<%= link_to 'Destroy', ibotta_path(x.id),
method: :delete %>
<% end %>
方法
def destroy
Ibotta.find(params[:id]).destroy
redirect_to ibotta_path
end
レーキルート
ibotta_save GET /ibotta/save(.:format) ibotta#save
ibotta_show GET /ibotta/show(.:format) ibotta#show
ibotta_delete GET /ibotta/delete(.:format) ibotta#delete
ibotta GET /ibotta(.:format) ibotta#index
POST /ibotta(.:format) ibotta#create
new_ibottum GET /ibotta/new(.:format) ibotta#new
edit_ibottum GET /ibotta/:id/edit(.:format) ibotta#edit
ibottum GET /ibotta/:id(.:format) ibotta#show
PATCH /ibotta/:id(.:format) ibotta#update
PUT /ibotta/:id(.:format) ibotta#update
DELETE /ibotta/:id(.:format) ibotta#destroy
私は例を少し変更して表現力豊かにしましたが、ここでは'@products.each do | x | 'を使っていますので、' <%= link_to 'Destroy' x、メソッド::delete%> ' –