我抓住了第一个国家
@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 '}
但我收到一条错误消息“没有给出块(产量)”
谢谢..remco