small medium large xlarge

17 May 2008, 01:01
Joseph Van Overberghe (2 posts)

Getting the following…


The html tags are in the database as <p> and <em> but when they are used in the code (snippet) below the are converted to &lt;p&gt; and &lt;em&gt; when viewed on the page source. So instead of being HTML tags the actual text is shown as above. What am I doing wrong? I am using XP, MYSQL5, ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32], and Rails 2.0.2.


<% for product in @products %>

<%=h product.title %>
<%=h truncate(product.description,80) %> .... `
17 May 2008, 02:11
Sam Ruby (634 posts)

You are doing it right, the image isn’t in sync.

Removing the “h” from the truncate line may help, but that depends on tags not being arbitrarily chopped. A better approach, and one that I am considering for future betss is something like the following:

<%=h truncate(product.description.gsub(/<.*?>/,''),80) %>
You must be logged in to comment