products_controller.rbのshowアクションに、productsテーブルから該当するidの作品情報を取得し@productの変数へ代入する処理を行いたいです。
Routing Error
No route matches [GET] "/products/280/reviews/new" とエラーが出てしまいました。
products_controller.rbには
Ruby
1class ProductsController < RankingController 2 def index 3 # productsテーブルから最新順に作品を20件取得する 4 @products = Product.limit(20).order('id DESC') 5 end 6 7 def shows 8 @product= Product.find(params[:id])←ここの部分 9 @title= Product.find(params[:title]) 10 end 11 12 def search 13 # 検索フォームのキーワードをあいまい検索して、productsテーブルから20件の作品情報を取得する 14 @products=Product.find_by_title(params[:title]) 15 @products=Product.order('id DESC').limit(20) 16 end 17end
と記載しました。
作品情報ごとにidがふられていて、自分ではどこが間違っているのかわかりません。
findメソットを使ったのが間違っているところなのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。