
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
Railsでワクワク個人開発 第5回: CRUD処理の規制と温度/湿度の登録 - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Railsでワクワク個人開発 第5回: CRUD処理の規制と温度/湿度の登録 - Qiita
class PlantsController < ApplicationController before_action :move_to_index, except: [:index, :sh... class PlantsController < ApplicationController before_action :move_to_index, except: [:index, :show] # ----中略---- def move_to_index # 自分以外のユーザーの植物の 編集/削除/新規作成はできない if (user_signed_in?) if (params[:user_id].to_i != current_user.id) redirect_to action: :index end elsif redirect_to action: :index end end # ----中略---- end before_actionはこのコントローラー内のアクションがよびだされたときにはじめに実行される。今回はmove_to_indexというメソッドが実行されるよ