我有一个列出小说的页面,我想显示每个相关插图的缩略图。我知道该关联正在工作,因为我可以显示每个关联插图对象的 toString 等效项。当我尝试遍历插图列表时,我得到:
undefined method `image_thumbnail_url' for #<ActiveRecord::Relation:0x007f023c07aa18>
这是代码:
<% if notice %>
<p id="notice"><%= notice %></p>
<% end %>
<h1 style="padding-left:25px">Archive Overview</h1>
<% @novels.each do |novel| %>
<div class="row">
<div class="span3" style="padding:0px 0px 25px 25px">
<%= link_to novel.name, novel %>
</div>
<div class="span4">
<p><%= novel.author%></p>
<p><%= novel.publisher %></p>
<p><%= novel.publication_date %></p>
</div>
<div class="span5">
<div style="display: none;"><%= illustrations = @novels.map{ |novel| novel.illustrations} %>
</div>
<ul>
<% illustrations.each do |illustration| %>
<li><%= illustration.image_thumbnail_url %></li>
<% end %>
</ul>
</div>
</div>