Monthly Archives: August 2007

Rails’ respond_to method

06-Aug-07

Ruby On Rails has a neat little feature called “respond_to”: class WeblogController < ActionController::Base def index @posts = Post.find :all respond_to do |format| format.html format.xml { render :xml => @posts.to_xml } format.rss { render :action => "feed.rxml" } end end endclass WeblogController < ActionController::Base def index @posts = Post.find :all respond_to do |format| format.html format.xml […]

Read the complete article »