Ruby on Rails 2.0入門:Flickerベースのアプリケーションの作成

http://japan.internet.com/developer/20080606/26.html

使用環境
Ruby 1.8.6 mswin32
Ruby on Rails 2.2.2
MySQL Community Server 5.0.77
NetBeans 6.5
Mongrel 1.1.5

respond_to

scaffold
respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @photos }
end

GET /photos HTTP/1.1
↓
HTTP/1.x 200 OK
Content-Type: text/html; charset=utf-8
GET /photos.xml HTTP/1.1
↓
HTTP/1.x 200 OK
Content-Type: application/xml; charset=utf-8
GET /photos.js HTTP/1.1
↓
HTTP/1.x 406 Not Acceptable
Content-Type: text/html; charset=utf-8
format.js を追加
respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @photos }
  format.js
end

GET /photos.js HTTP/1.1
↓
HTTP/1.x 200 OK
Content-Type: text/javascript; charset=utf-8

参考
優しいRailsの育て方 Controller#respond_to (The accept header) - ヽ( ・∀・)ノくまくまー
respond_toで指定されていないformatは406 Not Acceptableが返ってくる - これ僕.com:行動分析学マニアがおくる行動戦略
respond_to - api.rubyonrails.org