私はこのeach
ループを持っています: (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
@deals
3 つのテーブル (モデル) の結合されたクエリであるためpolymorphic_path
、画像のリンクを生成するために使用します。
- @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
しかし、これregion_city_attachment_path
は正しくないものを生成します。最初の各ループa
変数は正しい値を格納しますが、どうすれば2 番目のループでreach
最初の変数を保存できますか?a
each