2

This is probably really stupid but I've spent the last 2 hours trying to figure out how to do this with no luck at all.

Basically I need my html page to do the following:

<div class="circleElement">
...
</div>

But I need to add more classes to that div class with ruby, the classes are coming in from a text field in my database.

I tried inserting ruby like:

<div class="circleElement"+ <%= u.tag %> >...</div>

And many different variations of this line with no luck at all :(

I should add that u.tag holds exactly this string> "activeTag classicTag".... so it should append with no problems but it's not doing it!

0

1 Answer 1

6
<div class="circleElement <%= u.tag %>" >...</div>

should work.

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

2 Comments

OH MY GOD.... yes it did work. Thank you very very much!!! I was under the impression that <%= inside of double quotes would not get read as ruby!! This will open up many doors, it's so simple :)
In ERB, everything inside <% ... %> gets evaluated regardless of context. The exception is nesting where <%= " <%= ...%> " %> is not valid.

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.