提交 36b359f8 编写于 作者: S sealocal

document simple example of ActionController::MimeResponds#respond_to

上级 e5b9b7d2
...@@ -9,6 +9,13 @@ module MimeResponds ...@@ -9,6 +9,13 @@ module MimeResponds
# @people = Person.all # @people = Person.all
# end # 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: # Here's the same action, with web-service support baked in:
# #
# def index # def index
...@@ -16,11 +23,12 @@ module MimeResponds ...@@ -16,11 +23,12 @@ module MimeResponds
# #
# respond_to do |format| # respond_to do |format|
# format.html # format.html
# format.js
# format.xml { render xml: @people } # format.xml { render xml: @people }
# end # end
# 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." # 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.) # (Rails determines the desired response format from the HTTP Accept header submitted by the client.)
# #
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册