皆様、質問がございます、よろしくお願い申し上げます。
上記の問題について destroyアクションを生成し、削除を実行すると上記の問題が生じました。 予想している改善点 destroyアクションに対応するviewファイルは、redirect_toメソッドを扱っているため 生成する必要がないのですが、errorはtemplate missingとなっています。 そのため、reidrect_to以下のURLの指定(pins_path)を修正すれば良いと考えるのですが、どう対応したら良いのか分からない為、質問致します。
PinsController class PinsController < ApplicationController def new end def create @pin = Pin.new @pin.title = params[:title] @pin.description = params[:description] @pin.save redirect_to pin_path(@pin.id) end def index @pins = Pin.all end def show @pin = Pin.find(params[:id]) end def edit @pin = Pin.find(params[:id]) end def update @pin = Pin.find(params[:id]) @pin.title = params[:title] @pin.description = params[:description] @pin.save redirect_to pin_path(@pin.id) end def destroy @pin = Pin.find(params[:id]) @pin.destroy redirect_to pins_path end end
routes.rb PinBoard1::Application.routes.draw do get 'pins/new' => 'pins#new' post '/pins' => 'pins#create' get '/pins' => 'pins#index' get '/pins/:id' => 'pins#show', as: 'pin' patch '/pins/:id' => 'pins#update', as: 'update_pin' get '/pins/:id/edit' => 'pins#edit', as: 'edit_pin' delete '/pins/:id' => 'pins#destroy', as: 'destroy_pin' root 'home#top' get "/about" => 'home#about' end
Show.html.erb Title <p><%= @pin.title %></p> description <p><%= @pin.description %></p> <%= link_to "Edit", edit_pin_path(@pin.id), class: "btn edit_btn" %> <%= link_to "delete", destroy_pin_path(@pin.id), method: "delete", class: "btn destroy-btn", "date-confirm" => "Are you sure?" %>
よろしくお願い申し上げます。
失礼致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/18 13:50