I have a html.erb file where I have html code. I inserted this piece of ruby code
<li <%= puts "class='active'" %>>Link</li>
But when I run the code on rails server, class="active" is not rendered. Why is that and how do I fix it? Am I missing something basic and fundamental?
Don’t use puts. Use this:
putsprints a string to stdout and returnsnil. That’s why your class is not rendered.Update
To avoid escaping, prefix the string with
rawOr, if this is really what your code is (no simplification etc), you can just do