Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3854920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:41:48+00:00 2026-05-19T17:41:48+00:00

I’m looking for a best practice/standard pattern for generating feeds in Rails 3. Is

  • 0

I’m looking for a best practice/standard pattern for generating feeds in Rails 3. Is http://railscasts.com/episodes/87-generating-rss-feeds still valid?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:41:48+00:00Added an answer on May 19, 2026 at 5:41 pm

    First of all, nowadays I recommend using an ATOM feed instead of RSS.

    The specification of ATOM feed offers more value than the RSS one with internationalization, content types and other things and every modern feed reader supports it.

    More info about ATOM vs RSS can be found at:

    • the Wikipedia ATOM entry
    • PRO Blogger and Free Marketing Zone blog posts about the subject

    On to the coding:

    This example assumes:

    • a model called NewsItem with the following attributes:
    • title
    • content
    • author_name
    • a controller for that model (news_items_controller.rb), to which you’ll add the feed action

    We’ll use a builder template for this and the Ruby on Rails atom_feed helper which is of great use.

    1. Add the action to the controller

    Go to app/controllers/news_items_controller.rb and add:

    def feed
      # this will be the name of the feed displayed on the feed reader
      @title = "FEED title"
    
      # the news items
      @news_items = NewsItem.order("updated_at desc")
    
      # this will be our Feed's update timestamp
      @updated = @news_items.first.updated_at unless @news_items.empty?
    
      respond_to do |format|
        format.atom { render :layout => false }
    
        # we want the RSS feed to redirect permanently to the ATOM feed
        format.rss { redirect_to feed_path(:format => :atom), :status => :moved_permanently }
      end
    end
    

    2. Setup your builder template

    Now let’s add the template to build the feed.

    Go to app/views/news_items/feed.atom.builder and add:

    atom_feed :language => 'en-US' do |feed|
      feed.title @title
      feed.updated @updated
    
      @news_items.each do |item|
        next if item.updated_at.blank?
    
        feed.entry( item ) do |entry|
          entry.url news_item_url(item)
          entry.title item.title
          entry.content item.content, :type => 'html'
    
          # the strftime is needed to work with Google Reader.
          entry.updated(item.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ"))
    
          entry.author do |author|
            author.name entry.author_name
          end
        end
      end
    end
    

    3. Wire it up with a route

    Let’s make the feeds available at http://domain.example/feed

    This will call the action with the ATOM format by default and redirect /feed.rss to /feed.atom.

    Go to config/routes.rb and add:

    resources :news_items
    match '/feed' => 'news_items#feed',
          :as => :feed,
          :defaults => { :format => 'atom' }
    

    4. Add the link to ATOM and RSS feeds on the layout

    Finally, all that is left is to add the feed to the layout.

    Go to app/views/layouts/application.html.erb and add this your <head></head> section:

    <%= auto_discovery_link_tag :atom, "/feed" %>
    <%= auto_discovery_link_tag :rss, "/feed.rss" %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.