【发布时间】:2015-03-16 08:58:53
【问题描述】:
我有两个表:事件和图像
Events:
id
name
date
location
Images:
id
url (where it's hosted)
caption
event_id
事件有许多图像,但图像只有一个事件。因此,Event.id 连接到 Image.event_id。
我想创建一个页面,其中显示带有事件名称的图像,并且正在努力做到这一点。到目前为止,我只能在带有图像的页面上显示 event_id(这不是首选):
<div class="home-container">
<% @single_image.each do |picture| %>
<%= image_tag picture.url, :class => "body-images" %>
<li><%= link_to picture.event_id, events_path(picture.event_id), :class => "id-link" %></li>
<% end %>
</div>
任何帮助将不胜感激!
【问题讨论】:
标签: ruby-on-rails schema