助手不显示任何内容
Helper not showing anything
我有以下 rails 帮手:
def prefixes_with_tip shops
capture do
shops.each do |s|
content_tag(:span,class: 'has-tip',title: s.name) do
concat s.prefix
Rails.logger.debug "TEST TEST TEST #{s.name} TEST TEST TEST TEST TEST TEST TEST "
end
end
end
end
致电:
=prefixes_with_tip shop_list
在视图中调用时,我可以在控制台中看到痕迹,但视图中没有输出。
这个助手有什么问题?
(Rails 4.2)
问题是concat
怎么用,试试在外面content_tag
用,像这样:
def prefixes_with_tip shops
capture do
shops.each do |s|
concat content_tag(:span, s.prefix, class: 'has-tip',title: s.name)
end
end
end
注意 块 已被删除(否则 concat
将不起作用)并添加 s.prefix
作为第二个参数(设置 [= 标签的19=]内容。
我有以下 rails 帮手:
def prefixes_with_tip shops
capture do
shops.each do |s|
content_tag(:span,class: 'has-tip',title: s.name) do
concat s.prefix
Rails.logger.debug "TEST TEST TEST #{s.name} TEST TEST TEST TEST TEST TEST TEST "
end
end
end
end
致电:
=prefixes_with_tip shop_list
在视图中调用时,我可以在控制台中看到痕迹,但视图中没有输出。
这个助手有什么问题?
(Rails 4.2)
问题是concat
怎么用,试试在外面content_tag
用,像这样:
def prefixes_with_tip shops
capture do
shops.each do |s|
concat content_tag(:span, s.prefix, class: 'has-tip',title: s.name)
end
end
end
注意 块 已被删除(否则 concat
将不起作用)并添加 s.prefix
作为第二个参数(设置 [= 标签的19=]内容。