質問編集履歴
5
コード追記
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -246,112 +246,58 @@ | |
| 246 246 | 
             
            Rails 5.2.4.1
         | 
| 247 247 |  | 
| 248 248 | 
             
            ###追記
         | 
| 249 | 
            -
            
         | 
| 250 249 |  | 
| 251 | 
            -
             | 
| 250 | 
            +
            ####_follow_button.html.erb
         | 
| 251 | 
            +
            ```
         | 
| 252 | 
            +
            <% unless current_user == user %>
         | 
| 253 | 
            +
              <div id="follow_form_<%= user.id %>">
         | 
| 254 | 
            +
                <% if current_user.following?(user) %>
         | 
| 255 | 
            +
                  <%= form_for(current_user.relationships.find_by(follow_id: user.id), html: { method: :delete }, remote: true) do |f| %>
         | 
| 252 | 
            -
             | 
| 256 | 
            +
                    <%= hidden_field_tag :follow_id, user.id %>
         | 
| 257 | 
            +
                    <%= f.submit 'フォロー中' %>
         | 
| 258 | 
            +
                  <% end %>
         | 
| 259 | 
            +
                <% else %>
         | 
| 260 | 
            +
                  <%= form_for(current_user.relationships.build, remote: true) do |f| %>
         | 
| 261 | 
            +
                    <%= hidden_field_tag :follow_id, user.id %>
         | 
| 262 | 
            +
                    <%= f.submit 'フォローする' %>
         | 
| 263 | 
            +
                  <% end %>
         | 
| 264 | 
            +
                <% end %>
         | 
| 265 | 
            +
              </div>
         | 
| 266 | 
            +
            <% end %>
         | 
| 267 | 
            +
            ```
         | 
| 268 | 
            +
            ####create.js.erb, destroy.js.erb
         | 
| 269 | 
            +
            ```
         | 
| 270 | 
            +
            $("<%= @userid %>").html('<%= escape_javascript(render("relationships/follow_button", user: @user  )) %>');
         | 
| 271 | 
            +
            ```
         | 
| 253 272 |  | 
| 254 | 
            -
            非同期が出来ている箇所のログ
         | 
| 255 | 
            -
             | 
| 273 | 
            +
            ####relationships_controller.rb
         | 
| 256 | 
            -
             | 
| 257 274 | 
             
            ```
         | 
| 275 | 
            +
            class RelationshipsController < ApplicationController
         | 
| 276 | 
            +
              before_action :set_user
         | 
| 277 | 
            +
              
         | 
| 278 | 
            +
              def create
         | 
| 279 | 
            +
                following = current_user.follow(@user)
         | 
| 280 | 
            +
                following.save
         | 
| 281 | 
            +
                respond_to do |format|
         | 
| 258 | 
            -
             | 
| 282 | 
            +
                  format.html { redirect_to @user }
         | 
| 283 | 
            +
                  format.js
         | 
| 284 | 
            +
                end
         | 
| 285 | 
            +
              end
         | 
| 259 286 |  | 
| 260 | 
            -
            <div class="header">
         | 
| 261 | 
            -
              <nav class="navigation">
         | 
| 262 | 
            -
                <img src="/assets/logo.png">
         | 
| 263 | 
            -
             | 
| 287 | 
            +
              def destroy
         | 
| 264 | 
            -
                  <li>
         | 
| 265 | 
            -
                    <%= link_to "ログアウト", destroy_user_session_path, method: :delete %>
         | 
| 266 | 
            -
                  </li>
         | 
| 267 | 
            -
             | 
| 268 | 
            -
                  <li>
         | 
| 269 | 
            -
                    <%= link_to '投稿する', new_post_image_path %>
         | 
| 270 | 
            -
                  </li>
         | 
| 271 | 
            -
             | 
| 272 | 
            -
                  <li>
         | 
| 273 | 
            -
                    <%= link_to 'マイページ', user_path(current_user.id) %>
         | 
| 274 | 
            -
                  </li>
         | 
| 275 | 
            -
                </ul>
         | 
| 276 | 
            -
              </nav>
         | 
| 277 | 
            -
            </div>
         | 
| 278 | 
            -
            <div class="post_images_index_wrapper">
         | 
| 279 | 
            -
              <% @post_images.each do |post_image| %>
         | 
| 280 | 
            -
                 | 
| 288 | 
            +
                following = current_user.unfollow(@user)
         | 
| 289 | 
            +
                following.destroy if following
         | 
| 290 | 
            +
                respond_to do |format|
         | 
| 291 | 
            +
                  format.html { redirect_to @user }
         | 
| 292 | 
            +
                  format.js
         | 
| 293 | 
            +
                end
         | 
| 294 | 
            +
              end
         | 
| 295 | 
            +
              
         | 
| 296 | 
            +
              private
         | 
| 297 | 
            +
              
         | 
| 298 | 
            +
              def set_user
         | 
| 299 | 
            +
                @user = User.find(params[:follow_id])
         | 
| 281 | 
            -
             | 
| 300 | 
            +
                @userid = "#follow_form_#{@user.id}"
         | 
| 282 | 
            -
                    <ul>
         | 
| 283 | 
            -
                      <li>
         | 
| 284 | 
            -
                        <%= link_to user_path(post_image.user) do %>
         | 
| 285 | 
            -
                          <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
         | 
| 286 | 
            -
             | 
| 301 | 
            +
              end
         | 
| 287 | 
            -
                      </li>
         | 
| 288 | 
            -
                      <li>
         | 
| 289 | 
            -
                        <p><%= link_to "#{post_image.user.name}", user_path(post_image.user) %></p>
         | 
| 290 | 
            -
                      </li>
         | 
| 291 | 
            -
             | 
| 292 | 
            -
             | 
| 293 | 
            -
             | 
| 294 | 
            -
                      <li>
         | 
| 295 | 
            -
                        <%= render 'relationships/follow_button', user: post_image.user %>
         | 
| 296 | 
            -
                      </li>
         | 
| 297 | 
            -
             | 
| 298 | 
            -
             | 
| 299 | 
            -
             | 
| 300 | 
            -
                    </ul>
         | 
| 301 | 
            -
                  </div>
         | 
| 302 | 
            -
                  <div class="post_images_index_title">
         | 
| 303 | 
            -
                    <div class="image_title">
         | 
| 304 | 
            -
                      <h2>Real</h2>
         | 
| 305 | 
            -
                    </div>
         | 
| 306 | 
            -
                    <div class="image_title">
         | 
| 307 | 
            -
                      <h2>Cosplay</h2>
         | 
| 308 | 
            -
                    </div>
         | 
| 309 | 
            -
                  </div>
         | 
| 310 | 
            -
                  <div class="post_images_box">
         | 
| 311 | 
            -
                    <div class="post_image">
         | 
| 312 | 
            -
                      <%= link_to post_image_path(post_image) do %>
         | 
| 313 | 
            -
                        <%= attachment_image_tag post_image, :real_image %>
         | 
| 314 | 
            -
             | 
| 302 | 
            +
            end
         | 
| 315 | 
            -
                    </div>
         | 
| 316 | 
            -
                    <div class="post_image">
         | 
| 317 | 
            -
                      <%= link_to post_image_path(post_image) do %>
         | 
| 318 | 
            -
                        <%= attachment_image_tag post_image, :cosplay_image %>
         | 
| 319 | 
            -
                      <% end %>
         | 
| 320 | 
            -
                    </div>
         | 
| 321 | 
            -
                  </div>
         | 
| 322 | 
            -
                  <div class="image_name">
         | 
| 323 | 
            -
                    <%= post_image.real_image_name %>
         | 
| 324 | 
            -
                  </div>
         | 
| 325 | 
            -
                  <div class="image_name">
         | 
| 326 | 
            -
                    <%= post_image.cosplay_image_name %>
         | 
| 327 | 
            -
                  </div>
         | 
| 328 | 
            -
                  <div class="favorites_area">
         | 
| 329 | 
            -
                    <div class="favorite_area">
         | 
| 330 | 
            -
                      <%= render partial: 'post_images/post_images', locals: { post_image: post_image } %>
         | 
| 331 | 
            -
                    </div>
         | 
| 332 | 
            -
                    <div class="favorite_area">
         | 
| 333 | 
            -
                      <%= render partial: 'post_images/cosplay_post_images', locals: { post_image: post_image } %>
         | 
| 334 | 
            -
                    </div>
         | 
| 335 | 
            -
                  </div>
         | 
| 336 | 
            -
                  <div class="image_caption">
         | 
| 337 | 
            -
                    <ul>
         | 
| 338 | 
            -
                      <li>
         | 
| 339 | 
            -
                        <%= link_to user_path(post_image.id) do %>
         | 
| 340 | 
            -
                          <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
         | 
| 341 | 
            -
                        <% end %>
         | 
| 342 | 
            -
                      </li>
         | 
| 343 | 
            -
                      <li>
         | 
| 344 | 
            -
                        <p><%= link_to "#{post_image.user.name}", user_path(post_image.id) %> </p>
         | 
| 345 | 
            -
                      </li>
         | 
| 346 | 
            -
                      <li>
         | 
| 347 | 
            -
                        <p><%= link_to "#{post_image.post_comments.count}件のコメント", post_image_path(post_image.id) %></p>
         | 
| 348 | 
            -
                      </li>
         | 
| 349 | 
            -
                    </ul>
         | 
| 350 | 
            -
                    <span class="caption"><%= post_image.caption %></span>
         | 
| 351 | 
            -
                  </div>
         | 
| 352 | 
            -
                  <%= @a %>
         | 
| 353 | 
            -
                </div>
         | 
| 354 | 
            -
              <% end %>
         | 
| 355 | 
            -
              <%= paginate @post_images, class: "pagenate" %>
         | 
| 356 | 
            -
            </div>
         | 
| 357 303 | 
             
            ```
         | 
4
コード追加
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -252,4 +252,106 @@ | |
| 252 252 | 
             
            
         | 
| 253 253 |  | 
| 254 254 | 
             
            非同期が出来ている箇所のログ
         | 
| 255 | 
            -
            
         | 
| 255 | 
            +
            
         | 
| 256 | 
            +
             | 
| 257 | 
            +
            ```
         | 
| 258 | 
            +
            post_images/index.html.erb
         | 
| 259 | 
            +
             | 
| 260 | 
            +
            <div class="header">
         | 
| 261 | 
            +
              <nav class="navigation">
         | 
| 262 | 
            +
                <img src="/assets/logo.png">
         | 
| 263 | 
            +
                <ul>
         | 
| 264 | 
            +
                  <li>
         | 
| 265 | 
            +
                    <%= link_to "ログアウト", destroy_user_session_path, method: :delete %>
         | 
| 266 | 
            +
                  </li>
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                  <li>
         | 
| 269 | 
            +
                    <%= link_to '投稿する', new_post_image_path %>
         | 
| 270 | 
            +
                  </li>
         | 
| 271 | 
            +
             | 
| 272 | 
            +
                  <li>
         | 
| 273 | 
            +
                    <%= link_to 'マイページ', user_path(current_user.id) %>
         | 
| 274 | 
            +
                  </li>
         | 
| 275 | 
            +
                </ul>
         | 
| 276 | 
            +
              </nav>
         | 
| 277 | 
            +
            </div>
         | 
| 278 | 
            +
            <div class="post_images_index_wrapper">
         | 
| 279 | 
            +
              <% @post_images.each do |post_image| %>
         | 
| 280 | 
            +
                <div class="index_box">
         | 
| 281 | 
            +
                  <div class="post_images_index_user">
         | 
| 282 | 
            +
                    <ul>
         | 
| 283 | 
            +
                      <li>
         | 
| 284 | 
            +
                        <%= link_to user_path(post_image.user) do %>
         | 
| 285 | 
            +
                          <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
         | 
| 286 | 
            +
                        <% end %>
         | 
| 287 | 
            +
                      </li>
         | 
| 288 | 
            +
                      <li>
         | 
| 289 | 
            +
                        <p><%= link_to "#{post_image.user.name}", user_path(post_image.user) %></p>
         | 
| 290 | 
            +
                      </li>
         | 
| 291 | 
            +
             | 
| 292 | 
            +
             | 
| 293 | 
            +
             | 
| 294 | 
            +
                      <li>
         | 
| 295 | 
            +
                        <%= render 'relationships/follow_button', user: post_image.user %>
         | 
| 296 | 
            +
                      </li>
         | 
| 297 | 
            +
             | 
| 298 | 
            +
             | 
| 299 | 
            +
             | 
| 300 | 
            +
                    </ul>
         | 
| 301 | 
            +
                  </div>
         | 
| 302 | 
            +
                  <div class="post_images_index_title">
         | 
| 303 | 
            +
                    <div class="image_title">
         | 
| 304 | 
            +
                      <h2>Real</h2>
         | 
| 305 | 
            +
                    </div>
         | 
| 306 | 
            +
                    <div class="image_title">
         | 
| 307 | 
            +
                      <h2>Cosplay</h2>
         | 
| 308 | 
            +
                    </div>
         | 
| 309 | 
            +
                  </div>
         | 
| 310 | 
            +
                  <div class="post_images_box">
         | 
| 311 | 
            +
                    <div class="post_image">
         | 
| 312 | 
            +
                      <%= link_to post_image_path(post_image) do %>
         | 
| 313 | 
            +
                        <%= attachment_image_tag post_image, :real_image %>
         | 
| 314 | 
            +
                      <% end %>
         | 
| 315 | 
            +
                    </div>
         | 
| 316 | 
            +
                    <div class="post_image">
         | 
| 317 | 
            +
                      <%= link_to post_image_path(post_image) do %>
         | 
| 318 | 
            +
                        <%= attachment_image_tag post_image, :cosplay_image %>
         | 
| 319 | 
            +
                      <% end %>
         | 
| 320 | 
            +
                    </div>
         | 
| 321 | 
            +
                  </div>
         | 
| 322 | 
            +
                  <div class="image_name">
         | 
| 323 | 
            +
                    <%= post_image.real_image_name %>
         | 
| 324 | 
            +
                  </div>
         | 
| 325 | 
            +
                  <div class="image_name">
         | 
| 326 | 
            +
                    <%= post_image.cosplay_image_name %>
         | 
| 327 | 
            +
                  </div>
         | 
| 328 | 
            +
                  <div class="favorites_area">
         | 
| 329 | 
            +
                    <div class="favorite_area">
         | 
| 330 | 
            +
                      <%= render partial: 'post_images/post_images', locals: { post_image: post_image } %>
         | 
| 331 | 
            +
                    </div>
         | 
| 332 | 
            +
                    <div class="favorite_area">
         | 
| 333 | 
            +
                      <%= render partial: 'post_images/cosplay_post_images', locals: { post_image: post_image } %>
         | 
| 334 | 
            +
                    </div>
         | 
| 335 | 
            +
                  </div>
         | 
| 336 | 
            +
                  <div class="image_caption">
         | 
| 337 | 
            +
                    <ul>
         | 
| 338 | 
            +
                      <li>
         | 
| 339 | 
            +
                        <%= link_to user_path(post_image.id) do %>
         | 
| 340 | 
            +
                          <%= attachment_image_tag post_image.user, :profile_image, fallback: "no_image.jpg" %>
         | 
| 341 | 
            +
                        <% end %>
         | 
| 342 | 
            +
                      </li>
         | 
| 343 | 
            +
                      <li>
         | 
| 344 | 
            +
                        <p><%= link_to "#{post_image.user.name}", user_path(post_image.id) %> </p>
         | 
| 345 | 
            +
                      </li>
         | 
| 346 | 
            +
                      <li>
         | 
| 347 | 
            +
                        <p><%= link_to "#{post_image.post_comments.count}件のコメント", post_image_path(post_image.id) %></p>
         | 
| 348 | 
            +
                      </li>
         | 
| 349 | 
            +
                    </ul>
         | 
| 350 | 
            +
                    <span class="caption"><%= post_image.caption %></span>
         | 
| 351 | 
            +
                  </div>
         | 
| 352 | 
            +
                  <%= @a %>
         | 
| 353 | 
            +
                </div>
         | 
| 354 | 
            +
              <% end %>
         | 
| 355 | 
            +
              <%= paginate @post_images, class: "pagenate" %>
         | 
| 356 | 
            +
            </div>
         | 
| 357 | 
            +
            ```
         | 
3
ログ追加
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -247,4 +247,9 @@ | |
| 247 247 |  | 
| 248 248 | 
             
            ###追記
         | 
| 249 249 | 
             
            
         | 
| 250 | 
            +
             | 
| 251 | 
            +
            非同期が出来ていない箇所のログ
         | 
| 250 | 
            -
            
         | 
| 252 | 
            +
            
         | 
| 253 | 
            +
             | 
| 254 | 
            +
            非同期が出来ている箇所のログ
         | 
| 255 | 
            +
            
         | 
2
ログの追加
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -246,4 +246,5 @@ | |
| 246 246 | 
             
            Rails 5.2.4.1
         | 
| 247 247 |  | 
| 248 248 | 
             
            ###追記
         | 
| 249 | 
            -
            
         | 
| 249 | 
            +
            
         | 
| 250 | 
            +
            
         | 
1
エラー画像の追加
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -243,4 +243,7 @@ | |
| 243 243 |  | 
| 244 244 | 
             
            ### 補足情報(FW/ツールのバージョンなど)
         | 
| 245 245 | 
             
            ruby 2.5.7p206
         | 
| 246 | 
            -
            Rails 5.2.4.1
         | 
| 246 | 
            +
            Rails 5.2.4.1
         | 
| 247 | 
            +
             | 
| 248 | 
            +
            ###追記
         | 
| 249 | 
            +
            
         | 
