From 36b359f816b5a247be15ef5f01cacdc173700814 Mon Sep 17 00:00:00 2001 From: sealocal Date: Wed, 20 Jan 2016 23:39:46 -0800 Subject: [PATCH 1/2] document simple example of ActionController::MimeResponds#respond_to --- .../lib/action_controller/metal/mime_responds.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 MimeResponds # @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 MimeResponds # # 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.) # From 27a4e9345f1367e6bab99c68528ee91e1628c45c Mon Sep 17 00:00:00 2001 From: sealocal Date: Wed, 20 Jan 2016 23:41:07 -0800 Subject: [PATCH 2/2] remove doc reference to ActionController::MimeResponds#respond_to --- actionpack/lib/action_controller/metal/mime_responds.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb index a8f9c23b24..173a14a1d2 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -188,9 +188,6 @@ module MimeResponds # format.html.none # format.html.phone # this gets rendered # end - # - # Be sure to check the documentation of ActionController::MimeResponds.respond_to - # for more examples. def respond_to(*mimes) raise ArgumentError, "respond_to takes either types or a block, never both" if mimes.any? && block_given?