FYI:
- @dilemmas is populated in the controller via: @dilemmas =
Dilemma.find(:all)
- the Dilemma model has_many :dilemma_sides
- the DilemmaSide model belongs_to :dilemma
- the DilemmaSide model has_many :side_images
- the SideImage model belongs_to :dilemma_side
- side_images table has following attributes
# Table name: side_images
<% @dilemmas.each do |dilemma| %>
<% dilemma.dilemma_sides.each do |dilemma_side| %>
<% side_image = dilemma_side.side_images.first %>
<% if !side_image %>
Side <%= dilemma_side.id %> has no images
<% end %>
<%end%>
<% end %>
and see what it outputs.
Fred
Hey,
I've tried it, and as expected, it does not go into the loop. I am sure
that it is finding the Side Image belonging to the Dilemma Side. For
some strange reason, when I loop through the array which contains the
Side Images:
<% dilemma_side.side_images.each do |side_image|%>
<%= side_image.filename.to_s %>
<%end>
Then Rails allows me to access the attribute directly. I'm certainly
doing something wrong with instance variables assignments/declarations.
Is the code you're showing us cut-and-pasted from your views? It looks
like it might be a typo (like @side_image for side_image), so to rule
that out I wanted to be sure this is the actual template code.