syntax error, unexpected ‘

Home / Uncategorized / syntax error, unexpected ‘

Question:
I have been receiving the above mentioned error for a couple of hours now. I am working an a broadcast screen for a ruby project which needs to have a drop down menu that is linked to a skills table. I have generated the broadcast controller, and when editing the _form.html.erb file, I have been thrown a few syntax errors, attached are snippets of my files

I have tried moving the "<" around and completely out of the file but i still end up with errors.


Answer:
The error message says exactly where the problem is: _form.html.erb:27 where is used.

By the way, it’s not the only place, where <% %> pattern for html.erb is used incorrectly. The <%= form.label :skill> has no closing %>, that’s why everything that goes after until next %> is treated as a Ruby code. The code is incorrect and raises syntax error

In order to avoid syntax errors, the skill fieldset should be rewritten into this:

<%= form.label :skill %>
<%= form.collection_select :skill, Skill.order(:name), :name, :name, include_blank: "Select skill" %>

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *