質問編集履歴

5

コード追記

2020/02/09 14:29

投稿

is02
is02

スコア17

test CHANGED
File without changes
test CHANGED
@@ -494,220 +494,112 @@
494
494
 
495
495
  ###追記
496
496
 
497
- ![イメージ説明](a25315e9dc102d24af9d6f48230bf0cf.png)
498
-
499
-
500
-
501
- 非同期が出来ていない箇所のログ
502
-
503
- ![イメージ説明](660a3eee02010a23e7caaefc11761e13.png)
504
-
505
-
506
-
507
- 非同期が出来ている箇所のログ
508
-
509
- ![イメージ説明](40328551a4c54b208275166cf7459438.png)
510
-
511
-
512
-
513
- ```
514
-
515
- post_images/index.html.erb
516
-
517
-
518
-
519
- <div class="header">
520
-
521
- <nav class="navigation">
522
-
523
- <img src="/assets/logo.png">
524
-
525
- <ul>
526
-
527
- <li>
528
-
529
- <%= link_to "ログアウト", destroy_user_session_path, method: :delete %>
530
-
531
- </li>
532
-
533
-
534
-
535
- <li>
536
-
537
- <%= link_to '投稿する', new_post_image_path %>
538
-
539
- </li>
540
-
541
-
542
-
543
- <li>
544
-
545
- <%= link_to 'マイページ', user_path(current_user.id) %>
546
-
547
- </li>
548
-
549
- </ul>
550
-
551
- </nav>
552
-
553
- </div>
554
-
555
- <div class="post_images_index_wrapper">
556
-
557
- <% @post_images.each do |post_image| %>
558
-
559
- <div class="index_box">
560
-
561
- <div class="post_images_index_user">
562
-
563
- <ul>
564
-
565
- <li>
566
-
567
- <%= link_to user_path(post_image.user) do %>
568
-
569
- <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
570
-
571
- <% end %>
572
-
573
- </li>
574
-
575
- <li>
576
-
577
- <p><%= link_to "#{post_image.user.name}", user_path(post_image.user) %></p>
578
-
579
- </li>
580
-
581
-
582
-
583
-
584
-
585
-
586
-
587
- <li>
588
-
589
- <%= render 'relationships/follow_button', user: post_image.user %>
590
-
591
- </li>
592
-
593
-
594
-
595
-
596
-
597
-
598
-
599
- </ul>
600
-
601
- </div>
602
-
603
- <div class="post_images_index_title">
604
-
605
- <div class="image_title">
606
-
607
- <h2>Real</h2>
608
-
609
- </div>
610
-
611
- <div class="image_title">
612
-
613
- <h2>Cosplay</h2>
614
-
615
- </div>
616
-
617
- </div>
618
-
619
- <div class="post_images_box">
620
-
621
- <div class="post_image">
622
-
623
- <%= link_to post_image_path(post_image) do %>
624
-
625
- <%= attachment_image_tag post_image, :real_image %>
626
-
627
- <% end %>
628
-
629
- </div>
630
-
631
- <div class="post_image">
632
-
633
- <%= link_to post_image_path(post_image) do %>
634
-
635
- <%= attachment_image_tag post_image, :cosplay_image %>
636
-
637
- <% end %>
638
-
639
- </div>
640
-
641
- </div>
642
-
643
- <div class="image_name">
644
-
645
- <%= post_image.real_image_name %>
646
-
647
- </div>
648
-
649
- <div class="image_name">
650
-
651
- <%= post_image.cosplay_image_name %>
652
-
653
- </div>
654
-
655
- <div class="favorites_area">
656
-
657
- <div class="favorite_area">
658
-
659
- <%= render partial: 'post_images/post_images', locals: { post_image: post_image } %>
660
-
661
- </div>
662
-
663
- <div class="favorite_area">
664
-
665
- <%= render partial: 'post_images/cosplay_post_images', locals: { post_image: post_image } %>
666
-
667
- </div>
668
-
669
- </div>
670
-
671
- <div class="image_caption">
672
-
673
- <ul>
674
-
675
- <li>
676
-
677
- <%= link_to user_path(post_image.id) do %>
678
-
679
- <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
680
-
681
- <% end %>
682
-
683
- </li>
684
-
685
- <li>
686
-
687
- <p><%= link_to "#{post_image.user.name}", user_path(post_image.id) %> </p>
688
-
689
- </li>
690
-
691
- <li>
692
-
693
- <p><%= link_to "#{post_image.post_comments.count}件のコメント", post_image_path(post_image.id) %></p>
694
-
695
- </li>
696
-
697
- </ul>
698
-
699
- <span class="caption"><%= post_image.caption %></span>
700
-
701
- </div>
702
-
703
- <%= @a %>
704
-
705
- </div>
706
-
707
- <% end %>
708
-
709
- <%= paginate @post_images, class: "pagenate" %>
710
-
711
- </div>
712
-
713
- ```
497
+
498
+
499
+ ####_follow_button.html.erb
500
+
501
+ ```
502
+
503
+ <% unless current_user == user %>
504
+
505
+ <div id="follow_form_<%= user.id %>">
506
+
507
+ <% if current_user.following?(user) %>
508
+
509
+ <%= form_for(current_user.relationships.find_by(follow_id: user.id), html: { method: :delete }, remote: true) do |f| %>
510
+
511
+ <%= hidden_field_tag :follow_id, user.id %>
512
+
513
+ <%= f.submit 'フォロー中' %>
514
+
515
+ <% end %>
516
+
517
+ <% else %>
518
+
519
+ <%= form_for(current_user.relationships.build, remote: true) do |f| %>
520
+
521
+ <%= hidden_field_tag :follow_id, user.id %>
522
+
523
+ <%= f.submit 'フォローする' %>
524
+
525
+ <% end %>
526
+
527
+ <% end %>
528
+
529
+ </div>
530
+
531
+ <% end %>
532
+
533
+ ```
534
+
535
+ ####create.js.erb, destroy.js.erb
536
+
537
+ ```
538
+
539
+ $("<%= @userid %>").html('<%= escape_javascript(render("relationships/follow_button", user: @user )) %>');
540
+
541
+ ```
542
+
543
+
544
+
545
+ ####relationships_controller.rb
546
+
547
+ ```
548
+
549
+ class RelationshipsController < ApplicationController
550
+
551
+ before_action :set_user
552
+
553
+
554
+
555
+ def create
556
+
557
+ following = current_user.follow(@user)
558
+
559
+ following.save
560
+
561
+ respond_to do |format|
562
+
563
+ format.html { redirect_to @user }
564
+
565
+ format.js
566
+
567
+ end
568
+
569
+ end
570
+
571
+
572
+
573
+ def destroy
574
+
575
+ following = current_user.unfollow(@user)
576
+
577
+ following.destroy if following
578
+
579
+ respond_to do |format|
580
+
581
+ format.html { redirect_to @user }
582
+
583
+ format.js
584
+
585
+ end
586
+
587
+ end
588
+
589
+
590
+
591
+ private
592
+
593
+
594
+
595
+ def set_user
596
+
597
+ @user = User.find(params[:follow_id])
598
+
599
+ @userid = "#follow_form_#{@user.id}"
600
+
601
+ end
602
+
603
+ end
604
+
605
+ ```

4

コード追加

2020/02/09 14:29

投稿

is02
is02

スコア17

test CHANGED
File without changes
test CHANGED
@@ -507,3 +507,207 @@
507
507
  非同期が出来ている箇所のログ
508
508
 
509
509
  ![イメージ説明](40328551a4c54b208275166cf7459438.png)
510
+
511
+
512
+
513
+ ```
514
+
515
+ post_images/index.html.erb
516
+
517
+
518
+
519
+ <div class="header">
520
+
521
+ <nav class="navigation">
522
+
523
+ <img src="/assets/logo.png">
524
+
525
+ <ul>
526
+
527
+ <li>
528
+
529
+ <%= link_to "ログアウト", destroy_user_session_path, method: :delete %>
530
+
531
+ </li>
532
+
533
+
534
+
535
+ <li>
536
+
537
+ <%= link_to '投稿する', new_post_image_path %>
538
+
539
+ </li>
540
+
541
+
542
+
543
+ <li>
544
+
545
+ <%= link_to 'マイページ', user_path(current_user.id) %>
546
+
547
+ </li>
548
+
549
+ </ul>
550
+
551
+ </nav>
552
+
553
+ </div>
554
+
555
+ <div class="post_images_index_wrapper">
556
+
557
+ <% @post_images.each do |post_image| %>
558
+
559
+ <div class="index_box">
560
+
561
+ <div class="post_images_index_user">
562
+
563
+ <ul>
564
+
565
+ <li>
566
+
567
+ <%= link_to user_path(post_image.user) do %>
568
+
569
+ <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
570
+
571
+ <% end %>
572
+
573
+ </li>
574
+
575
+ <li>
576
+
577
+ <p><%= link_to "#{post_image.user.name}", user_path(post_image.user) %></p>
578
+
579
+ </li>
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+ <li>
588
+
589
+ <%= render 'relationships/follow_button', user: post_image.user %>
590
+
591
+ </li>
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+ </ul>
600
+
601
+ </div>
602
+
603
+ <div class="post_images_index_title">
604
+
605
+ <div class="image_title">
606
+
607
+ <h2>Real</h2>
608
+
609
+ </div>
610
+
611
+ <div class="image_title">
612
+
613
+ <h2>Cosplay</h2>
614
+
615
+ </div>
616
+
617
+ </div>
618
+
619
+ <div class="post_images_box">
620
+
621
+ <div class="post_image">
622
+
623
+ <%= link_to post_image_path(post_image) do %>
624
+
625
+ <%= attachment_image_tag post_image, :real_image %>
626
+
627
+ <% end %>
628
+
629
+ </div>
630
+
631
+ <div class="post_image">
632
+
633
+ <%= link_to post_image_path(post_image) do %>
634
+
635
+ <%= attachment_image_tag post_image, :cosplay_image %>
636
+
637
+ <% end %>
638
+
639
+ </div>
640
+
641
+ </div>
642
+
643
+ <div class="image_name">
644
+
645
+ <%= post_image.real_image_name %>
646
+
647
+ </div>
648
+
649
+ <div class="image_name">
650
+
651
+ <%= post_image.cosplay_image_name %>
652
+
653
+ </div>
654
+
655
+ <div class="favorites_area">
656
+
657
+ <div class="favorite_area">
658
+
659
+ <%= render partial: 'post_images/post_images', locals: { post_image: post_image } %>
660
+
661
+ </div>
662
+
663
+ <div class="favorite_area">
664
+
665
+ <%= render partial: 'post_images/cosplay_post_images', locals: { post_image: post_image } %>
666
+
667
+ </div>
668
+
669
+ </div>
670
+
671
+ <div class="image_caption">
672
+
673
+ <ul>
674
+
675
+ <li>
676
+
677
+ <%= link_to user_path(post_image.id) do %>
678
+
679
+ <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
680
+
681
+ <% end %>
682
+
683
+ </li>
684
+
685
+ <li>
686
+
687
+ <p><%= link_to "#{post_image.user.name}", user_path(post_image.id) %> </p>
688
+
689
+ </li>
690
+
691
+ <li>
692
+
693
+ <p><%= link_to "#{post_image.post_comments.count}件のコメント", post_image_path(post_image.id) %></p>
694
+
695
+ </li>
696
+
697
+ </ul>
698
+
699
+ <span class="caption"><%= post_image.caption %></span>
700
+
701
+ </div>
702
+
703
+ <%= @a %>
704
+
705
+ </div>
706
+
707
+ <% end %>
708
+
709
+ <%= paginate @post_images, class: "pagenate" %>
710
+
711
+ </div>
712
+
713
+ ```

3

ログ追加

2020/02/09 05:20

投稿

is02
is02

スコア17

test CHANGED
File without changes
test CHANGED
@@ -496,4 +496,14 @@
496
496
 
497
497
  ![イメージ説明](a25315e9dc102d24af9d6f48230bf0cf.png)
498
498
 
499
+
500
+
501
+ 非同期が出来ていない箇所のログ
502
+
499
503
  ![イメージ説明](660a3eee02010a23e7caaefc11761e13.png)
504
+
505
+
506
+
507
+ 非同期が出来ている箇所のログ
508
+
509
+ ![イメージ説明](40328551a4c54b208275166cf7459438.png)

2

ログの追加

2020/02/07 09:24

投稿

is02
is02

スコア17

test CHANGED
File without changes
test CHANGED
@@ -495,3 +495,5 @@
495
495
  ###追記
496
496
 
497
497
  ![イメージ説明](a25315e9dc102d24af9d6f48230bf0cf.png)
498
+
499
+ ![イメージ説明](660a3eee02010a23e7caaefc11761e13.png)

1

エラー画像の追加

2020/02/07 09:22

投稿

is02
is02

スコア17

test CHANGED
File without changes
test CHANGED
@@ -489,3 +489,9 @@
489
489
  ruby 2.5.7p206
490
490
 
491
491
  Rails 5.2.4.1
492
+
493
+
494
+
495
+ ###追記
496
+
497
+ ![イメージ説明](a25315e9dc102d24af9d6f48230bf0cf.png)