質問編集履歴

1

一部間違った情報を書いていました。

2019/11/14 12:39

投稿

yamada_yuuki
yamada_yuuki

スコア100

test CHANGED
File without changes
test CHANGED
@@ -286,13 +286,23 @@
286
286
 
287
287
  ```ugblogrb
288
288
 
289
- class Ugsama < ApplicationRecord
289
+ class Ugblog < ApplicationRecord
290
-
290
+
291
- belongs_to :ugblog
291
+ has_many :ugsama
292
+
292
-
293
+ mount_uploader :img, ImgUploader
293
-
294
-
294
+
295
+
296
+
295
- validates :kome, presence: { message: 'は、必須項です。' }
297
+ validates :title, :subtitle, :Text, :img, presence: {message:'は、必須項です。'}
298
+
299
+ def self.search(search)
300
+
301
+ return Ugblog.all unless search
302
+
303
+ Ugblog.where(['content LIKE ?', "%#{search}%"])
304
+
305
+ end
296
306
 
297
307
  end
298
308