Ruby on Rails初心者です。
独学で学んでおります。
リファクタリングしようとbefore_action :set_list, only: [:show, :edit, :update, :destroy]のようにまとめてみた際に発生しました。
色々と試しているのですが、どこが問題なのかわからず苦戦しています。
初歩的な質問で申し訳ございませんが、教えていただけると幸甚です!
ActiveRecord::RecordNotFound in ListsController#edit Couldn't find List with 'id'=7 def set_list ** @list = List.find params[:id]** end end
class ListsController < ApplicationController before_action :set_list, only: [:show, :edit, :update, :destroy] def index @list = List.all end def show end def new @list = List.new end def edit end def create @list = List.new(list_params) if @list.save redirect_to list_path(@list) else render 'new' end end def update if @list.update(list_params) redirect_to @list else render 'edit' end end def destroy @list.destroy redirect_to list_path end def list_params params.require(:list).permit(:image, :title, :text) end def set_list @list = List.find params[:id] end end
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。