0

我有一个 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 行附近):”中为红色

4

1 回答 1

1

尝试使用:

:"enable_#{search_param[:name]}"
于 2013-10-01T08:04:01.720 回答