I have this each loop: (haml)
- @deals.each do |a|
.slide
%a{:href => "#"}
- a.attachments.each do |a|
= image_tag(a.file.url, :height =>"325px", :width =>"650px" )
.caption{:style => "bottom:0"}
= a.description
Because @deals is combined query of 3 tables (models) I use polymorphic_path to generate the links of the images.
- @deals.each do |a|
.slide
%a{:href => "#"}
- a.attachments.each do |a|
= image_tag(a.file.url, :height =>"325px", :width =>"650px" ), polymorphic_path(@region, @city, a)
.caption{:style => "bottom:0"}
= a.description
But this generates region_city_attachment_path which is not correct. The first each loop a variable store the correct value, but how can I reach the first a variable in the second each loop?
Just give it another name.