0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Rails】furimaアプリ 商品削除機能 #1

Posted at

実装概要

商品の情報を削除する機能を実装

ルーティングの設定

config/routes.rb
resources :items

今回で7つ目のアクションなのでonly:~以下は削除してまとめる

destroyアクションをコントローラーに定義

app/controllers/items_controller.rb
before_action :authenticate_user!, only: [:new, :create, :edit, :update, :destroy]
before_action :set_item, only: [:edit, :show, :update, :destroy]
before_action :correct_user, only: [:edit, :update, :destroy]

# 中略

 def destroy
    @item.destroy
    redirect_to root_path
 end

以上で実装完了
LGTMいただいたので次回は商品購入機能の実装に取り組んでいきます!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?