0

SyntaxError occurs when:

<% @list1.each do |list| %>
  <div class="well well-sm">
    <%= list.test_name %> <%= link_to 'Do It', '#', class: <%= list.test_type %>
  </div>
<% end %>
  

Tried also class: <%= #{list}.test_type %> and so on... what's wrong with it?

2 Answers 2

1

You have excess erb open tag <%=, instead:

<%= list.test_name %> <%= link_to 'Do It', '#', class: <%= list.test_type %>
^^^open          close^^  ^^open                                     ^^^open       close^^

use:

<%= list.test_name %> <%= link_to 'Do It', '#', class: list.test_type %>

I suggest you read An Introduction to ERB Templating

Sign up to request clarification or add additional context in comments.

Comments

0

try this:

 <%= link_to 'Do It', '#', class: list.test_type  %>

or

<%= link_to 'Do It', '#', class: "#{list.test_type}" %>

1 Comment

thanks! It was all about single quotes that i tried early after "class:" :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.