显示image_path和上传的图像

时间:2019-01-09 10:10:15

标签: html ruby-on-rails image carrierwave actionview

当我将图像上传到图像时,图像下方会显示一段不需要的文本。 here is a screenshot 该视图文件具有以下代码:

<li id="project-<%= project.id %>">
  <%= link_to gravatar_for(project.user, size: 50), project.user %>
  <span class="user"><%= link_to project.user.name, project.user %></span>
  <span class="content">
    <%= project.title %>
    <%= project.content %>
    <%= project.pictures.each do |p| %>
    <%= image_tag p.url %>
    <% end %>
  </span>
  <span class="timestamp">
    Posted <%= time_ago_in_words(project.created_at) %> ago.
    <% if current_user?(project.user) %>
    <%= link_to "delete", project, method: :delete, data: { confirm: "You sure?"} %>
    <%= link_to "edit", "/projects/#{project.id}/edit", method: :get %>
    <% end %>
  </span>
</li>

任何建议或帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

您的错误在这里<%= project.pictures.each do |p| %>

将其更改为:

<% project.pictures.each do |p| %>