Hi, i have a text field in html format "It is a <span>sunny </span> day. <br> Bye" When i put in the rhtml <%= news.text_field %> I get printed the text with the tags inside.... is there a to_html or soemthing like that?
thanks
Christian
Hi, i have a text field in html format "It is a <span>sunny </span> day. <br> Bye" When i put in the rhtml <%= news.text_field %> I get printed the text with the tags inside.... is there a to_html or soemthing like that?
thanks
Christian
You may need to provide some more information about what your trying to do.
An HTML Text field, or textarea will not render as html. They only contain text. Perhaps something like tinyMCE or similar javascript powered rich editor is what your after.
Daniel
I will try to explain it better... It is not for editing or creating a text. I already have the text in my table-database
I have <% for new in @news %> Title:<h1><%= new.title.to_s %></h1> <br> <%= new.title.text %> <br> <%end>
And the text field has html tags inside (divs and spans) The result is that the text printed is with the tags.For example
Title: New Member in the Society The society wants to <span class="bold">announce</span> that: <br> Mr etc, etc Title: New Member in the Society The society wants to <span class="bold">announce</span> that: <br> Mr etc, etc
Where does the text method come from in this line?
<%= new.title.text %>
It seems that title is an attribute of the AR model, but there is no text method that I know of on String. What kind of object is it?
sorry....
<%= new.text %>
text is the name of the field
thanks
Cool. That makes more sense to me.
There is nothing imediate that jumps to mind except that at some point it seems that the tags are being escaped.
If you select these directly from the database, or using the console. Is the markup like
The society wants to announce
that:
Mr etc, etc
Or is the tags escaped? Like
The society wants to <span class=“bold”&gr;announce</span> that: <br> Mr etc, etc
In the screen I get it The society wants to <span class="bold">announce</span> that: <br> Mr etc, etc
The society wants to <span class="bold"&gr;announce</span> that: <br> Mr etc, etc
I get it printed like The society wants to <span class="bold">announce</span> that: <br> Mr etc, etc
but in the Page Source it is tags escaped ....
The society wants to <span class="bold"&gr;announce</span> that: <br> Mr etc, etc
I found the problem.
I had <%=h new.text %>
not <%= new.text %>
Anyway thank you very much Daniel