Home>

I'm trying to call a part of the display in Rails view
I'm really in trouble without getting a syntax error

<% def check_label (id, label)%>
<input type = "checkbox">
<label for = "<% = id%>"><% = label%></label>
<% end%>
<% def check_list (label, values)%>
<div>
  <a data-toggle = "collapse" data-parent = "# condition" href = "#<% = label%>s">
    <label><% = t (label)%></label>
  </a>
  <div>
    <% for v in values ​​do%>
    <div>
      <% = check_label (label + '_' + v, t (label + 's.' + v))%>
    </div>
    <% end%>
  </div>
</div>
<% end%>
It's a view called
<% = check_label (label + '_' + v, t (label + 's.' + v))%>


Syntax error, unexpected',&apos ;, expecting')'

I'm sorry for the low level questions
Just one line of syntax error doesn't tell you why for over 30 minutes ...

  • Answer # 1

      

    check_label (label +'_'+ v, t (label +'s.'+ v))

    Modify
    I'm sorry, in the first place, it wasn't a matter of arguments in this way.
    What was supposed to be an argument was not even an argument.
    No space is required between the method and the argument.

    First of all, no such argument can be specified.

    def foo (hoge, huga)
      p hoge
      p huga
    end
    foo ("aaa" + "bbb", 'ccc')


    I think you should try and prepare this method appropriately.

    foo ("aaa" + "bbb", 'ccc')


    You can't do it without space. If you write like this, you should use# {}.

    Second, regarding errors that can occur after this, sincevis an Integer type, it cannot be combined with a String type and+