我虎視眈眈的第一個國家與應用程序控制器中的全局變量?
@country = Country.find(1)
然後我我的頭導航我讓這個循環可以得到正確的標籤:
%ul.thumbnails
- @country.tags.find_each(:conditions => "active_house = true") do |a|
%li.span2
.thumbnail
- a.attachments.limit(1).each do |b|
= image_tag(b.file.url)
.caption
%p
#{link_to a.url, tag_country_region_houses_path(@country, a.name), :class => 'btn-nav-drop'}
這工作得很好。但導航是全球性的,所以我在application_controller創建的方法是這樣的:
helper_method :tags
def tags
@country = Country.find(1)
@tags = @country.tags.find_each(:conditions => "active_house = true")
end
而且在導航視圖:
%ul.thumbnails
- tags do |a|
%li.span2
.thumbnail
- a.attachments.limit(1).each do |b|
= image_tag(b.file.url)
.caption
%p
#{link_to a.url, tag_country_houses_path(@country, a.name), :class => 'btn-nav-drop '}
但我得到一個錯誤消息「沒有塊給出(收益率)」
Thanks..remco