aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-12-12 07:59:17 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-12-12 07:59:17 -0800
commit1454f2c20a988e320f4f9466caae83b59f959c3b (patch)
treea4d7b152507a951fd8d12be6ff59d0feddb51d45 /actionpack
parent02a81b84ebb7fc16dc2ae4609277e8251f232f95 (diff)
parent3ce9563d42cbec3db69ac31161532460b84abe3a (diff)
downloadrails-1454f2c20a988e320f4f9466caae83b59f959c3b.tar.gz
rails-1454f2c20a988e320f4f9466caae83b59f959c3b.tar.bz2
rails-1454f2c20a988e320f4f9466caae83b59f959c3b.zip
Merge pull request #13290 from strzalek/inline-syntax-docs
Variants inline syntax documentation
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md8
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb9
2 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 102be1bdca..b4d3da3603 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -47,6 +47,14 @@
app/views/projects/show.html+tablet.erb
app/views/projects/show.html+phone.erb
+ You can also simplify the variants definition using the inline syntax:
+
+ respond_to do |format|
+ format.js { render "trash" }
+ format.html.phone { redirect_to progress_path }
+ format.html.none { render "trash" }
+ end
+
*Łukasz Strzałkowski*
* Fix header `Content-Type: #<Mime::NullType:...>` in localized template.
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index dedff9f476..60fababd83 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -209,6 +209,15 @@ module ActionController #:nodoc:
# app/views/projects/show.html+tablet.erb
# app/views/projects/show.html+phone.erb
#
+ # When you're not sharing any code within the format, you can simplify defining variants
+ # using the inline syntax:
+ #
+ # respond_to do |format|
+ # format.js { render "trash" }
+ # format.html.phone { redirect_to progress_path }
+ # format.html.none { render "trash" }
+ # end
+ #
# Be sure to check the documentation of +respond_with+ and
# <tt>ActionController::MimeResponds.respond_to</tt> for more examples.
def respond_to(*mimes, &block)