0
我想有一个条件类的方法帮助如何在方法助手中创建条件类?
product_helper.rb
def product_icon
...
elsif product.sent?
'<div class="green-text <%= 'middle' if current_action?(controller: 'products', action: 'index')" %> ><i class="fa fa-envelope-o" aria-hidden="true"></i></div>'.html_safe
end
但我得到这个错误:
syntax error, unexpected keyword_class, expecting keyword_end
'<div <%= 'class="middle if current_acti...
^
谢谢,我完全忘记了这个细节!但是在视图中不会将其解释为html,即使使用'#{...}',你知道为什么吗?即使使用'.html_safe'也可以使用 – Orsay
? – Fallenhero
是的,即使是.html_safe。这是确切的视图渲染: