Values not showing -- embedded ruby within innerHTML of anchor tag

155 views Asked by At

I have an embedded ruby layout file for a navbar. The innerHTML of the anchor tag holds an embedded ruby snippet calling the value of the string.

<% text_var = "check string" %>
<a id="show_string" class="brand" ><% text_var %></a>

RESULTS

  • Blank title for anchor tag
  • Rails did not throw an error page

If I have instead <a id="show_string" class="brand" >This is Plain Text</a> then it displays "This is Plain Text" as the title of the anchor tag.

  • Is there a conflict with the embedded ruby and the innerHTML?
  • Syntax / Use of embedded ruby incorrect?
1

There are 1 answers

2
yujingz On BEST ANSWER

try

<a id="show_string" class="brand" ><%= text_var %></a>

You need the = sign to display the string