質問編集履歴

1

追記

2019/04/08 15:47

投稿

tatu0
tatu0

スコア19

test CHANGED
File without changes
test CHANGED
@@ -60,4 +60,22 @@
60
60
 
61
61
  <% end %>
62
62
 
63
+
64
+
65
+ ・post.rb
66
+
67
+ class Post < ApplicationRecord
68
+
69
+
70
+
71
+ def self.search(search)
72
+
73
+ return Post.all unless search
74
+
75
+ Post.where(['body LIKE ?', "%#{search}%"])
76
+
77
+ end
78
+
79
+ end
80
+
63
81
  ```