Ruby on rails 辅助对象中的捕获\u haml不显示参数值
我试图在rails视图中使用一个助手来绘制一些haml行,事实是它正在编写html标记,但其中没有内容 这是我的助手:Ruby on rails 辅助对象中的捕获\u haml不显示参数值,ruby-on-rails,haml,helper,Ruby On Rails,Haml,Helper,我试图在rails视图中使用一个助手来绘制一些haml行,事实是它正在编写html标记,但其中没有内容 这是我的助手: def detail_line(model, column, value) capture_haml do haml_tag :div, class: 'control-group' do haml_tag :label, {class: 'control-label'},"#{model.class.human_attribute_name col
def detail_line(model, column, value)
capture_haml do
haml_tag :div, class: 'control-group' do
haml_tag :label, {class: 'control-label'},"#{model.class.human_attribute_name column}"
haml_tag :div, class: 'controls' do
haml_tag :div, {class: 'value'}, "#{value}"
end
end
end
end
下面是我使用它的方式:
= detail_line(@order, 'number', @order.number)
输出如下:
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<div class="value"></div>
</div>
</div>
我错过了什么或做错了什么?
提前非常感谢 试试这个:-=detail_行(@order,'number',@order.number).html_safe@Rubyman感谢您的回复,但它没有起作用:(试试这个:-=detail_行(@order,'number',@order.number).html_safe@Rubyman感谢您的回复,但它不起作用:(是的!这成功了!我必须在haml_标记函数中切换参数顺序。谢谢!是的!这成功了!我必须在haml_标记函数中切换参数顺序。谢谢!
def detail_line(model, column, value)
capture_haml do
haml_tag :div, class: 'control-group' do
haml_tag :label,"#{model.class.human_attribute_name column}", {class: 'control-label'}
haml_tag :div, class: 'controls' do
haml_tag :div, "#{value}", {class: 'value'}
end
end
end
end