質問編集履歴

2

タイトルの修正

2021/07/03 23:28

投稿

kraax73
kraax73

スコア1

test CHANGED
@@ -1 +1 @@
1
- Rails 並び替え機能を実装したい
1
+ Ruby on Rails 商品の並び替え機能を実装したい
test CHANGED
File without changes

1

JSのコードを修正しました

2021/07/03 23:28

投稿

kraax73
kraax73

スコア1

test CHANGED
File without changes
test CHANGED
@@ -90,13 +90,13 @@
90
90
 
91
91
  @products = Product.all.order('price DESC')
92
92
 
93
+ elsif params[:option] == "created_at_asc"
94
+
95
+ @products = Product.all.order('created_at ASC')
96
+
93
- elsif params[:option] == "created_at desc"
97
+ elsif params[:option] == "created_at_desc"
94
98
 
95
99
  @products = Product.all.order('created_at DESC')
96
-
97
- elsif params[:option] == "created_at asc"
98
-
99
- @products = Product.all.order('created_at ASC')
100
100
 
101
101
  end
102
102