Image_tag在show上生成额外数据

时间:2015-12-23 18:48:48

标签: ruby-on-rails image ruby-on-rails-4 show

我有一个带回形针的嵌套图像的图像标记。

图像显示效果不错,但我的情况如下:

[#<图片ID:8,post_id:7,created_at:“2015-12-23 18:37:33”,updated_at:“2015-12-23 18:37:33”,image_file_name:“Clichey3 .png“,image_content_type:”image / png“,image_file_size:93529,image_updated_at:”2015-12-23 18:37:33“>]

Bug

这是我的节目:

<p id="notice"><%= notice %></p>
<%= @post.pictures.each do |pic| %>
  <%= image_tag(pic.image.url(:medium)) %>
<% end %>
<p>
  <strong>Title:</strong>
  <%= @post.title %>
</p>

<p>
  <strong>Description:</strong>
  <%= @post.description %>
</p>

<%= link_to 'Edit', edit_post_path(@post) %> |
<%= link_to 'Back', posts_path %>

很奇怪?有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我认为这与此有关,你不希望循环上有'='。我忘记了它是' - 还是没有。

<% @post.pictures.each do |pic| %>
  <%= image_tag(pic.image.url(:medium)) %>
<% end %>