Ruby on rails Rails 4自定义助手方法,其形式为';无法查看输出-完全
我在Ruby on rails Rails 4自定义助手方法,其形式为';无法查看输出-完全,ruby-on-rails,forms,view-helpers,Ruby On Rails,Forms,View Helpers,我在application\u helper.rb中有这个,因为我对许多模型使用相同的过滤形式 def filter_form(path, filter_options, button) form_tag(path, remote: true, method: "get") do label_tag(:filter, "Filter by") select_tag(:filter_type, options_for_select(filter_options))
application\u helper.rb
中有这个,因为我对许多模型使用相同的过滤形式
def filter_form(path, filter_options, button)
form_tag(path, remote: true, method: "get") do
label_tag(:filter, "Filter by")
select_tag(:filter_type, options_for_select(filter_options))
"<span>for:</span>".html_safe
text_field_tag(:filter)
button_tag(:submit, "Submit") if button == true
end
end
def过滤器表单(路径、过滤器选项、按钮)
form_标记(路径,远程:true,方法:“get”)do
标签标签(:筛选,“筛选依据”)
选择标签(:过滤器类型,过滤器选项)
“用于:”.html\u安全
文本\字段\标记(:过滤器)
按钮标签(:submit,“submit”),如果按钮==true
结束
结束
例如,在我的用户文章中
<%= filter_form(articles_path, @filter_options, false) %>
然而,在代码中,我可以看到它只生成了
标记,这一切都很好,但是没有显示任何表单元素。为什么会这样?尝试使用
def过滤器表单(路径、过滤器选项、按钮)
form_标记(路径,远程:true,方法:“get”)do
concat标签\标签(:过滤器,“过滤器依据”)
concat select_标记(:过滤器类型,过滤器选项)
“用于:”.html\u安全
concat文本\字段\标记(:过滤器)
concat按钮标签(:submit,“submit”),如果按钮==true
结束
结束
有一篇好文章你需要使用
concat
在哪里?就像在每一行的结尾或哪里
def filter_form(path, filter_options, button)
form_tag(path, remote: true, method: "get") do
concat label_tag(:filter, "Filter by")
concat select_tag(:filter_type, options_for_select(filter_options))
"<span>for:</span>".html_safe
concat text_field_tag(:filter)
concat button_tag(:submit, "Submit") if button == true
end
end