# do the things that make the controller awesome. My railtie might look something like: # lib/acts_as_awesome/railtie.rbĪnd(:extend, ActsAsAwesome::Hook)Īnd the ActsAsAwesome::Hook code: # lib/acts_as_awesome/hook.rb So, if I were implementing an acts_as_* gem, I'd start there. Rails 3 makes use of a really useful feature called Railtie - see. I'm not aware of another tutorial source off the top of my head, but here are some general tips. UPDATE: I've added a blog post based on this answer, but with much more detail: Here, the RSS feed XML is generated and returned to HTTP. This is where all the Railsy magic happens.
RUBY RSS BUILDER SOFTWARE
Xml.description "A blog about software and chocolate" Views/posts/ xml.instruct! :xml, :version => "1.0" The name of this file should match the controller. # we want the RSS feed to redirect permanently to the ATOM feedįormat.rss #
RUBY RSS BUILDER UPDATE
# this will be our Feed's update = unless do |format| # the news = NewsItem.order("updated_at desc") # this will be the name of the feed displayed on the feed = "FEED title" Go to app/controllers/news_items_controller.rb and add: def feed We'll use a builder template for this and the Ruby on Rails atom_feed helper which is of great use.
RUBY RSS BUILDER PRO
RUBY RSS BUILDER CODE
This code will spit out an Atom feed with one item. to_s end end puts rssĪs you can see, this is a very Builder-like DSL. title = " Ruby 1.9.2-p136 is released " item. Let’s make a very basic feed: require " rss " rss = RSS :: Maker. Producing our own RSS feeds is easy as well. This example shows getting the title out of the channel element,Īnd looping through the list of items. We getīack an object that has all of the data from our feed, accessible through Of the feed and a parameter that performs validation on the feed. parse ( rss ) puts " Title: # " end endĪs you can see, the workhorse is RSS::Parser#parse, which takes the source This, but we’ll need the help of open-uri: require ' rss ' require ' open-uri ' url = ' ' open ( url ) do | rss | feed = RSS :: Parser. Your Ruby code, you’ve come to the right place.
If you’d like to read someone’s RSS feed with Links to the standards documents for these formats: The standard library supports RSS 0.91, 1.0, 2.0,Īnd Atom, a related format. Of the standard library provides tooling to read and create these feeds. Subscribe and receive updates from a particular web service. Really Simple Syndication ( RSS) is a family ofįormats that describe ‘feeds,’ specially constructed XML documents that allow an interested person to Frozen_string_literal: false RSS reading and writing