회사의 이벤트 데이터를 가져올 수는 있지만 해당 이벤트에 연결된 사진을 가져올 수는 없습니다.링크가있는 Has_Many가있는 레일 사진
<% 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 %>
회사 컨트롤러 I가 종이 클립을 사용하고
def show
@company = Company.find(params[:id])
end
처럼
회사 has_many 이벤트 & 이벤트 has_many 사진
현재 회사/쇼에 내 코드 보인다 내 이미지. 어떤 도움이라도 대단히 감사 할 것입니다.
코드 형태의 이벤트 모델 (내가 회사에서 액세스를 시도하고 명심)
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
내가 가진 @event = Event.where (: COMPANY_ID => : ID : 순서 => 'DESC') 내 CONTROLER에있는 순간 –
'@event = Event.where (: COMPANY_ID => (PARAMS [: ID])) ' 내 show 액션이 호출 '<% = IMAGE_TAG @event %> ' 결과 빈 이미지 이것이에 도시 HTML '' –
문서 클립을 제대로 설정하지 않았습니다. r 이벤트 모델. 해당 연결에 대한 코드를 붙여넣고 질문을 편집하십시오. –