質問編集履歴

2

変更

2019/07/30 10:29

投稿

k_yusuke
k_yusuke

スコア19

test CHANGED
File without changes
test CHANGED
@@ -292,8 +292,6 @@
292
292
 
293
293
  @tour=Tour.find_by(id: params[:id])
294
294
 
295
- @like=Like.new
296
-
297
295
  @comments = Comment.where(tour_id: @tour.id)
298
296
 
299
297
  @comment = Comment.new
@@ -390,6 +388,8 @@
390
388
 
391
389
  input_html: { autocomplete: "content",class:"form-control" }
392
390
 
391
+ =hidden_field_tag :tour_id,@tour.id
392
+
393
393
  = f.button :submit, "Comment!",
394
394
 
395
395
  input_html: { class:" btn btn-primary " }

1

変更

2019/07/30 10:28

投稿

k_yusuke
k_yusuke

スコア19

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  rails tutorialの応用で記事(tourモデル)に対してコメントする機能を実装中です。
6
6
 
7
- `app/wiews/tours/show/index.html.haml`にコメントを反映させたいと考えています。
7
+ `app/wiews/tours/show.html.haml`にコメントを反映させたいと考えています。
8
8
 
9
9
  ↓の記事を参考にしました
10
10
 
@@ -308,7 +308,7 @@
308
308
 
309
309
  ```
310
310
 
311
- app/wiews/tours/show/index.html.haml
311
+ app/wiews/tours/show.html.haml
312
312
 
313
313
  ```ruby
314
314
 
@@ -396,6 +396,48 @@
396
396
 
397
397
  ```
398
398
 
399
+ app/wiews/tours/index.html.haml
400
+
401
+ ```ruby
402
+
403
+ %h1.page_title tour一覧
404
+
405
+ =render "shared/search"
406
+
407
+ = page_entries_info @tours
408
+
409
+ = paginate @tours
410
+
411
+ -@tours.each do |tour|
412
+
413
+ .card
414
+
415
+ .card-body
416
+
417
+ %h4.card-title
418
+
419
+ %smallタイトル:
420
+
421
+ #{tour.tourname}
422
+
423
+ %h6.card-subtitle.mb-2.text-muted
424
+
425
+ %small製作者:
426
+
427
+ #{tour.user.username}
428
+
429
+ %p.card-text
430
+
431
+ = tour.tourcontent
432
+
433
+ = link_to "詳細",tour_path(tour.id),class:"card-link"
434
+
435
+ = paginate @tours
436
+
437
+
438
+
439
+ ```
440
+
399
441
  app/config/routes.rb
400
442
 
401
443
  ```ruby