我有一个叫
FeaturesHelper
的帮手,它有一些功能的数据:
feature_info = [
{features:
[
{
description: "This is a #{view_context.link_to "link!", "https://www.example.com", target: :_blank, class: "pink-link"}",
}
]
}, ...]
然后我有一个部分使用
feature_info
:
<% feature_info.each do |info|%>
<% info[:features].each do |feature| %>
<%= feature[:description].html_safe %>
<% end %>
<% end %>
然后我在视图中渲染部分:
<%= render partial: "partial_name" %>
这导致错误,堆栈跟踪指向 no my
FeaturesHelper
:
#ActionView::Base:0x007f80a6cdcf20 的未定义局部变量或方法“view_context”