aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorsealocal <local.mat@gmail.com>2016-01-20 23:39:46 -0800
committersealocal <local.mat@gmail.com>2016-01-20 23:39:46 -0800
commit36b359f816b5a247be15ef5f01cacdc173700814 (patch)
tree439a06fe775df31e08e68728628184b5edd0a775 /actionpack
parente5b9b7d25d3ff3a641adea43dd2bd88625d1da20 (diff)
downloadrails-36b359f816b5a247be15ef5f01cacdc173700814.tar.gz
rails-36b359f816b5a247be15ef5f01cacdc173700814.tar.bz2
rails-36b359f816b5a247be15ef5f01cacdc173700814.zip
document simple example of ActionController::MimeResponds#respond_to
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 6e346fadfe..a8f9c23b24 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -9,6 +9,13 @@ module ActionController #:nodoc:
# @people = Person.all
# end
#
+ # That action implicitly responds to all formats, but formats can also be whitelisted:
+ #
+ # def index
+ # @people = Person.all
+ # respond_to :html, :js
+ # end
+ #
# Here's the same action, with web-service support baked in:
#
# def index
@@ -16,11 +23,12 @@ module ActionController #:nodoc:
#
# respond_to do |format|
# format.html
+ # format.js
# format.xml { render xml: @people }
# end
# end
#
- # What that says is, "if the client wants HTML in response to this action, just respond as we
+ # What that says is, "if the client wants HTML or JS in response to this action, just respond as we
# would have before, but if the client wants XML, return them the list of people in XML format."
# (Rails determines the desired response format from the HTTP Accept header submitted by the client.)
#