Build a RSS feed in Ruby on Rails : Lugo Labs
Building a RSS feed in Ruby on Rails is very easy, it feels like almost built in. We'll use the XML Builder handler that comes with Rails, so let's get started.
Let's assume we want to add the feed to our company blog, made of Article models. Each article has a title and a body property. The ArticlesController is a normal CRUD Rails controller; we'll add the feed to the index action, so let's update that now:
ruby
# app/controllers/articles_controller.rb class ArticlesController < ApplicationController def index @articles = Article.last(10) respond_to do |format| format.html format.rss { render :layout => false } end end end
The code above just removes the... [more...]
→ 4 Articles (and 1 Videos) for this topic
Check also :
Build a RSS feed in Ruby on Rails : Lugo Labs
Building a RSS feed in Ruby on Rails is very easy, it feels like almost built in. We'll use the XML Builder handler that comes with Rails, so let's get started.
Let's assume we want to add the feed to our company blog, made of Article models. Each article has a title and a body property. The ArticlesController is a normal CRUD Rails controller; we'll add the feed to the index action, so let's update that now:
ruby
# app/controllers/articles_controller.rb class ArticlesController < ApplicationController def index @articles = Article.last(10) respond_to do |format| format.html format.rss { render :layout => false } end end end
The code above just removes the...
Website:
http://www.lugolabs.com
Related topics : rails rss feed builder / rails rss feed reader / rails rss feed / rss feed reader code html / ruby on rails rss reader
1 Resources