我有一个form_for表单助手:
= form_for([@search, @search_request], url: {action: @search_form[:search_action]}, method: @search_form[:http_method], remote: true, html: {id: @search_form[:html_id]}, data: {type: "json"}) do |search_current_form|
- @search_params.each do |search_param|
= render partial: "search/search_param", locals: {search_param: search_param, search_form: @search_form, search_current_form: search_current_form, search_request: @search_request}
部分在search/search_param
:
.input-group
span.input-group-addon
= search_current_form.check_box(:search_request, :#{"enable_" + search_param[:name]}, {class: "param_enabled_checkbox"}, true, false)
= search_current_form.text_field(:search_request, :#{"param_" + search_param[:name]}, {class: "param_value_input"})
但是我收到了一个错误:
SyntaxError
Showing ./app/views/search/_search_param.html.slim where line #19 raised:
./app/views/search/_search_param.html.slim:19: syntax error, unexpected ';', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
; @output_buffer.safe_concat((...
^
./app/views/search/_search_param.html.slim:20: syntax error, unexpected ';', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
; @output_buffer.safe_concat(("</div></td></tr>")); @output_buffer
^
./app/views/search/_search_param.html.slim:21: syntax error, unexpected keyword_ensure, expecting ')'
./app/views/search/_search_param.html.slim:23: syntax error, unexpected keyword_end, expecting ')'
可能是什么问题?参数数量错误:
= search_form.text_field(:search_request, :#{"param_" + search_param[:name]}, {class: "param_value_input"})
?该行在“提取的来源(第19行附近)中为红色:”
答案 0 :(得分:1)
尝试使用:
:"enable_#{search_param[:name]}"