Hi -- On Sun, 30 Nov 2008, John Doe wrote:
> > >> How about you change your code to >> >> <% @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. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS (Jan 12-15), Fort Lauderdale, FL See http://www.rubypal.com for details Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

