0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

likes.html.erb

Posted at
">

<%= @user.name %>

<%= @user.email %>

<% if @user.id == @current_user.id %> <%= link_to("編集", "/users/#{@user.id}/edit") %> <% end %>
<ul class="user-tabs">
  <li><%= link_to("投稿", "/users/#{@user.id}") %></li>
  <li class="active"><%= link_to("いいね!", "/users/#{@user.id}/likes") %></li>
</ul>

<!-- 変数@likesに対してeach文を用いてください -->
<% @likes.each do |like| %>
  <!-- 変数postを定義してください -->
  <% post = Post.find_by(id: like.post_id) %>
  
  <div class="posts-index-item">
    <div class="post-left">
      <img src="<%= "/user_images/#{post.user.image_name}" %>">
    </div>
    <div class="post-right">
      <div class="post-user-name">
        <%= link_to(post.user.name, "/users/#{post.user.id}") %>
      </div>
      <%= link_to(post.content, "/posts/#{post.id}") %>
    </div>
  </div>
<!-- each文のendを追加してください -->
<% end %>
//いいね機能を実装する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?