Created
December 12, 2011 20:47
-
-
Save afeld/1469020 to your computer and use it in GitHub Desktop.
using HTML in a RSS feed in Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><%= record.name %></h1> | |
<!-- etc --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@records.each do |record| | |
xml.item do | |
xml.title record.name | |
xml.description do | |
desc = render :partial => 'body', :locals => {:record => record} | |
desc = simple_format desc # preserves newlines by converting to <p> tags | |
xml.cdata! desc # wrap the HTML content in CDATA tags | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stumbled upon this recently. I was running into this:
MissingTemplateException
. The error looked like such:Two options to address this exception:
_body.html.erb
to_body.rss.erb
or:formats
to render, like sorender :partial => 'body', :locals => { :record => record }, :formats => [:html]