In my HTML I have a span
<span style="color:#??????> <h3>Title</h3> </span>
Okay, in my database I have records which have a field that store the hash color value of a span, example #123456 , with the hash included.
Now what I want to do is in the HTML, instead of me specifying the colour, it is retrieved directly from the database.
The model is called Sauce. The field is called title_colour.
I have tried:
<span style="color: #{sauce.title_colour}">...</span>
The problem is that when the HTML is output, it is exactly as it is in the code. It does not extract the database value.
I think the problem is because in Rails when we display an object when already in quote marks, we start with a #, eg #{sauce.field_name} , and in CSS the color value also starts with a #.
Any help?
You need to use the proper erb interpolation tags: