0

I am using the Feedjira gem, trying to render img_src.

//My Controller

def index
  Feedjira::Feed.add_common_feed_entry_element("image")
  feed = Feedjira::Feed.fetch_and_parse("http://cltampa.com/tampa/Rss.xml?section=2065818") 
  @entry = feed.entries
end

//My View

<% @entry.each do |t|%>
   <h3><%= link_to t.title, t.url %></h3>
   <p><%= t.published %></p>
   <p><%= t.summary %></p>
<% end %>

The view displays everything correctly, just trying to figure out how to display the actual image instead of the image url. I have seen a couple posts on this, but I am a little lost. I don't quite understand what is going on under the hood, after following the docs as well. Any help is appreciated.

Danny Sullivan
  • 277
  • 2
  • 12

1 Answers1

1

Use sanitize. In your DB, the image-field is like , and when you try to "display" it in your view, rails still give you the url. What you can do is to use sanitize

Ex.

<% @entry.each do |t|%>
   <h3><%= link_to t.title, t.url %></h3>
   <p><%= t.published %></p>
   <p><%= sanitize t.summary %></p>
<% end %>

This will give a thumbs-up to rails and "display" the "code" as a actual image.