0

I have a form_for form helper:

  = 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}

partial in 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"})

But I get an error:

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 ')'

What could be the problem? Wrong number of arguments in:

= search_form.text_field(:search_request, :#{"param_" + search_param[:name]}, {class: "param_value_input"})

? This line is red in the "Extracted source (around line #19):"

static
  • 8,126
  • 15
  • 63
  • 89

1 Answers1

1

Try to use:

:"enable_#{search_param[:name]}"
Oleg Haidul
  • 3,682
  • 1
  • 22
  • 14
  • already had this before, so after change I get another error but even in the line before: `undefined method \`merge' for :enable_user_id:Symbol` – static Oct 01 '13 at 08:06
  • and if I do so as I have - the error rises only in the next line. – static Oct 01 '13 at 08:08
  • this was an error I asked before: http://stackoverflow.com/questions/19105260/how-should-look-a-form-helper-for-nested-resources?rq=1 – static Oct 01 '13 at 08:13
  • I think, this can help http://stackoverflow.com/questions/4721058/undefined-method-merge-for-2fixnum – Oleg Haidul Oct 01 '13 at 08:20
  • yes, the `check_box_tag` works, but I want to go to model-bound variant – static Oct 01 '13 at 08:32