使用Feedjira解析图像
问题描述:
我正在使用Feedjira gem,试图呈现img_src。使用Feedjira解析图像
//我的控制器
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
//我查看
<% @entry.each do |t|%>
<h3><%= link_to t.title, t.url %></h3>
<p><%= t.published %></p>
<p><%= t.summary %></p>
<% end %>
的观点正确显示的一切,只是想弄清楚如何显示实际图像而不是图像的URL。我已经看到了一些帖子,但我有点失落。我也不太明白,在遵循这些文档之后,发生了什么。任何帮助表示赞赏。
答
使用清洁。 在你的数据库中,图像字段就像,当你试图在你的视图中“显示”它时,rails仍会给你提供url。 您可以做的是使用消毒
Ex。
<% @entry.each do |t|%>
<h3><%= link_to t.title, t.url %></h3>
<p><%= t.published %></p>
<p><%= sanitize t.summary %></p>
<% end %>
这会给竖起大拇指并将“代码”显示为实际图像。