#87 Generating RSS Feeds (revised)
May 26, 2012 | 8 minutes | Views
If you have a page containing a dynamic list of records, consider providing an RSS or Atom feed for it. It is quite easy to do with XML Builder and the atom_feed helper method as shown in this episode.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
Thanks for the update Ryan. For some reason my html was being interpreted as plain text and escaped so had to add this:
Thanks.. I ran into this as well!
You can also add
feed.icon '/assets/icons/feed.gif'
For the atom feed, does anyone know how to add an image for each article? I've seen some websites that do that.
This is what I'm experimenting with, not sure if there's a better way:
entry << "<media:thumbnail url=\"#{post.thumbnail.tiny}\" width='200' height='200' />".html_safe
nm, that doesn't work. I added an image to the summary but that doesn't seem to work either. Still looking for a solution.
This one the other hand will work.
Hi,
I got 2 models, "User" and "Memberships". Each user has multiple memberships (has_many), and each membership belongs_to an user.
My question is: How do I loop thru each user and each membership? My idea was to build 2 loops, but its not working =/ (Unknown method 'each' for users?)
How can we use fragment caching w/ this?
I'm wondering like @swrobel how we can incorporate fragment caching?
I like to tell you that i like this post very much you are providing the best information.
Lets say I have News and Blog Posts and I have feed for both of these. Do you recommend it from SEO perspective. Should I try to provide a single feed or separate feed depending on the controller. As shown in this railscast. Or have a separate FeedController and have one feed?
Why do you actually want to hack something?