我可以提供公司联系的事件数据,但无法提供与该事件有关的照片。
Company has_many Events & Event has_many Photos
www.un.org/spanish/ecosoc 目前,我的公司/公司守则就好像。
<% if @company.events.exists? then %>
<% @company.events.offset(1).each do |event| %>
<li><h3><%= link_to "#{event.name}", {:controller => "events", :action => "show", :id => event.id}, :rel => "external" %></h3>
<p>By <%= event.artist %></p></li>
<%= image_tag event.photo.photo.url(:large) %>
<% end %>
<% else %>
<p> There are no current events attached</p>
<% end %>
<>Companyller>
def show
@company = Company.find(params[:id])
end
I am using Paperclip for my Images. Any help would be much appreciated.
法典 活动模式 (考虑到我试图从公司进入Keep)
class Event < ActiveRecord::Base
attr_accessible :name, :description, :artist, :starttime, :startdate, :finishdate, :company_id, :photos_attributes
belongs_to :company
has_many :photos
accepts_nested_attributes_for :photos, :allow_destroy => true, :reject_if => lambda { |a| a[:photo].blank? }
accepts_nested_attributes_for :company
end