actionpack 7.1.5.1 → 7.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -642
  3. data/lib/abstract_controller/asset_paths.rb +2 -0
  4. data/lib/abstract_controller/base.rb +102 -98
  5. data/lib/abstract_controller/caching/fragments.rb +50 -53
  6. data/lib/abstract_controller/caching.rb +2 -0
  7. data/lib/abstract_controller/callbacks.rb +66 -64
  8. data/lib/abstract_controller/collector.rb +6 -6
  9. data/lib/abstract_controller/deprecator.rb +2 -0
  10. data/lib/abstract_controller/error.rb +2 -0
  11. data/lib/abstract_controller/helpers.rb +70 -85
  12. data/lib/abstract_controller/logger.rb +2 -0
  13. data/lib/abstract_controller/railties/routes_helpers.rb +2 -0
  14. data/lib/abstract_controller/rendering.rb +13 -12
  15. data/lib/abstract_controller/translation.rb +12 -13
  16. data/lib/abstract_controller/url_for.rb +8 -6
  17. data/lib/abstract_controller.rb +2 -0
  18. data/lib/action_controller/api/api_rendering.rb +2 -0
  19. data/lib/action_controller/api.rb +74 -72
  20. data/lib/action_controller/base.rb +155 -117
  21. data/lib/action_controller/caching.rb +15 -12
  22. data/lib/action_controller/deprecator.rb +2 -0
  23. data/lib/action_controller/form_builder.rb +20 -17
  24. data/lib/action_controller/log_subscriber.rb +3 -1
  25. data/lib/action_controller/metal/allow_browser.rb +119 -0
  26. data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
  27. data/lib/action_controller/metal/conditional_get.rb +188 -174
  28. data/lib/action_controller/metal/content_security_policy.rb +25 -24
  29. data/lib/action_controller/metal/cookies.rb +4 -2
  30. data/lib/action_controller/metal/data_streaming.rb +64 -55
  31. data/lib/action_controller/metal/default_headers.rb +5 -3
  32. data/lib/action_controller/metal/etag_with_flash.rb +3 -1
  33. data/lib/action_controller/metal/etag_with_template_digest.rb +17 -15
  34. data/lib/action_controller/metal/exceptions.rb +11 -9
  35. data/lib/action_controller/metal/flash.rb +12 -10
  36. data/lib/action_controller/metal/head.rb +12 -10
  37. data/lib/action_controller/metal/helpers.rb +63 -55
  38. data/lib/action_controller/metal/http_authentication.rb +214 -203
  39. data/lib/action_controller/metal/implicit_render.rb +17 -15
  40. data/lib/action_controller/metal/instrumentation.rb +15 -12
  41. data/lib/action_controller/metal/live.rb +113 -107
  42. data/lib/action_controller/metal/logging.rb +6 -4
  43. data/lib/action_controller/metal/mime_responds.rb +151 -142
  44. data/lib/action_controller/metal/parameter_encoding.rb +34 -32
  45. data/lib/action_controller/metal/params_wrapper.rb +57 -59
  46. data/lib/action_controller/metal/permissions_policy.rb +13 -12
  47. data/lib/action_controller/metal/rate_limiting.rb +62 -0
  48. data/lib/action_controller/metal/redirecting.rb +108 -82
  49. data/lib/action_controller/metal/renderers.rb +50 -49
  50. data/lib/action_controller/metal/rendering.rb +103 -75
  51. data/lib/action_controller/metal/request_forgery_protection.rb +162 -133
  52. data/lib/action_controller/metal/rescue.rb +11 -9
  53. data/lib/action_controller/metal/streaming.rb +138 -136
  54. data/lib/action_controller/metal/strong_parameters.rb +483 -478
  55. data/lib/action_controller/metal/testing.rb +2 -0
  56. data/lib/action_controller/metal/url_for.rb +17 -15
  57. data/lib/action_controller/metal.rb +58 -57
  58. data/lib/action_controller/railtie.rb +3 -0
  59. data/lib/action_controller/railties/helpers.rb +2 -0
  60. data/lib/action_controller/renderer.rb +42 -36
  61. data/lib/action_controller/template_assertions.rb +4 -2
  62. data/lib/action_controller/test_case.rb +146 -126
  63. data/lib/action_controller.rb +5 -1
  64. data/lib/action_dispatch/constants.rb +2 -0
  65. data/lib/action_dispatch/deprecator.rb +2 -0
  66. data/lib/action_dispatch/http/cache.rb +27 -26
  67. data/lib/action_dispatch/http/content_disposition.rb +2 -0
  68. data/lib/action_dispatch/http/content_security_policy.rb +48 -59
  69. data/lib/action_dispatch/http/filter_parameters.rb +13 -14
  70. data/lib/action_dispatch/http/filter_redirect.rb +15 -1
  71. data/lib/action_dispatch/http/headers.rb +22 -22
  72. data/lib/action_dispatch/http/mime_negotiation.rb +30 -41
  73. data/lib/action_dispatch/http/mime_type.rb +25 -21
  74. data/lib/action_dispatch/http/mime_types.rb +2 -0
  75. data/lib/action_dispatch/http/parameters.rb +11 -9
  76. data/lib/action_dispatch/http/permissions_policy.rb +26 -36
  77. data/lib/action_dispatch/http/rack_cache.rb +2 -0
  78. data/lib/action_dispatch/http/request.rb +75 -95
  79. data/lib/action_dispatch/http/response.rb +61 -61
  80. data/lib/action_dispatch/http/upload.rb +18 -16
  81. data/lib/action_dispatch/http/url.rb +75 -73
  82. data/lib/action_dispatch/journey/formatter.rb +13 -6
  83. data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
  84. data/lib/action_dispatch/journey/gtg/simulator.rb +2 -0
  85. data/lib/action_dispatch/journey/gtg/transition_table.rb +10 -8
  86. data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
  87. data/lib/action_dispatch/journey/nodes/node.rb +6 -5
  88. data/lib/action_dispatch/journey/parser.rb +4 -3
  89. data/lib/action_dispatch/journey/parser_extras.rb +2 -0
  90. data/lib/action_dispatch/journey/path/pattern.rb +4 -1
  91. data/lib/action_dispatch/journey/route.rb +9 -7
  92. data/lib/action_dispatch/journey/router/utils.rb +16 -15
  93. data/lib/action_dispatch/journey/router.rb +4 -2
  94. data/lib/action_dispatch/journey/routes.rb +4 -2
  95. data/lib/action_dispatch/journey/scanner.rb +4 -2
  96. data/lib/action_dispatch/journey/visitors.rb +2 -0
  97. data/lib/action_dispatch/journey.rb +2 -0
  98. data/lib/action_dispatch/log_subscriber.rb +2 -0
  99. data/lib/action_dispatch/middleware/actionable_exceptions.rb +2 -0
  100. data/lib/action_dispatch/middleware/assume_ssl.rb +8 -5
  101. data/lib/action_dispatch/middleware/callbacks.rb +3 -1
  102. data/lib/action_dispatch/middleware/cookies.rb +119 -104
  103. data/lib/action_dispatch/middleware/debug_exceptions.rb +13 -5
  104. data/lib/action_dispatch/middleware/debug_locks.rb +15 -13
  105. data/lib/action_dispatch/middleware/debug_view.rb +2 -0
  106. data/lib/action_dispatch/middleware/exception_wrapper.rb +6 -11
  107. data/lib/action_dispatch/middleware/executor.rb +2 -0
  108. data/lib/action_dispatch/middleware/flash.rb +63 -51
  109. data/lib/action_dispatch/middleware/host_authorization.rb +17 -15
  110. data/lib/action_dispatch/middleware/public_exceptions.rb +8 -6
  111. data/lib/action_dispatch/middleware/reloader.rb +5 -3
  112. data/lib/action_dispatch/middleware/remote_ip.rb +77 -72
  113. data/lib/action_dispatch/middleware/request_id.rb +14 -9
  114. data/lib/action_dispatch/middleware/server_timing.rb +4 -2
  115. data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -0
  116. data/lib/action_dispatch/middleware/session/cache_store.rb +13 -8
  117. data/lib/action_dispatch/middleware/session/cookie_store.rb +27 -26
  118. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -3
  119. data/lib/action_dispatch/middleware/show_exceptions.rb +16 -16
  120. data/lib/action_dispatch/middleware/ssl.rb +43 -40
  121. data/lib/action_dispatch/middleware/stack.rb +11 -10
  122. data/lib/action_dispatch/middleware/static.rb +33 -31
  123. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +1 -1
  124. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +1 -1
  125. data/lib/action_dispatch/railtie.rb +2 -3
  126. data/lib/action_dispatch/request/session.rb +23 -21
  127. data/lib/action_dispatch/request/utils.rb +2 -0
  128. data/lib/action_dispatch/routing/endpoint.rb +2 -0
  129. data/lib/action_dispatch/routing/inspector.rb +6 -4
  130. data/lib/action_dispatch/routing/mapper.rb +623 -625
  131. data/lib/action_dispatch/routing/polymorphic_routes.rb +69 -62
  132. data/lib/action_dispatch/routing/redirection.rb +37 -32
  133. data/lib/action_dispatch/routing/route_set.rb +60 -46
  134. data/lib/action_dispatch/routing/routes_proxy.rb +6 -4
  135. data/lib/action_dispatch/routing/url_for.rb +130 -125
  136. data/lib/action_dispatch/routing.rb +150 -148
  137. data/lib/action_dispatch/system_test_case.rb +91 -81
  138. data/lib/action_dispatch/system_testing/browser.rb +4 -2
  139. data/lib/action_dispatch/system_testing/driver.rb +2 -0
  140. data/lib/action_dispatch/system_testing/server.rb +2 -0
  141. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +32 -21
  142. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
  143. data/lib/action_dispatch/testing/assertion_response.rb +8 -6
  144. data/lib/action_dispatch/testing/assertions/response.rb +26 -23
  145. data/lib/action_dispatch/testing/assertions/routing.rb +153 -84
  146. data/lib/action_dispatch/testing/assertions.rb +2 -0
  147. data/lib/action_dispatch/testing/integration.rb +223 -222
  148. data/lib/action_dispatch/testing/request_encoder.rb +2 -0
  149. data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
  150. data/lib/action_dispatch/testing/test_process.rb +12 -8
  151. data/lib/action_dispatch/testing/test_request.rb +3 -1
  152. data/lib/action_dispatch/testing/test_response.rb +27 -26
  153. data/lib/action_dispatch.rb +22 -32
  154. data/lib/action_pack/gem_version.rb +6 -4
  155. data/lib/action_pack/version.rb +3 -1
  156. data/lib/action_pack.rb +17 -16
  157. metadata +33 -16
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  require "set"
4
6
 
5
7
  module ActionController
@@ -13,7 +15,7 @@ module ActionController
13
15
  Renderers.remove(key)
14
16
  end
15
17
 
16
- # See <tt>Responder#api_behavior</tt>
18
+ # See `Responder#api_behavior`
17
19
  class MissingRenderer < LoadError
18
20
  def initialize(format)
19
21
  super "No renderer defined for format: #{format}"
@@ -24,7 +26,7 @@ module ActionController
24
26
  extend ActiveSupport::Concern
25
27
 
26
28
  # A Set containing renderer names that correspond to available renderer procs.
27
- # Default values are <tt>:json</tt>, <tt>:js</tt>, <tt>:xml</tt>.
29
+ # Default values are `:json`, `:js`, `:xml`.
28
30
  RENDERERS = Set.new
29
31
 
30
32
  included do
@@ -42,35 +44,34 @@ module ActionController
42
44
  end
43
45
  end
44
46
 
45
- # Adds a new renderer to call within controller actions.
46
- # A renderer is invoked by passing its name as an option to
47
- # AbstractController::Rendering#render. To create a renderer
48
- # pass it a name and a block. The block takes two arguments, the first
49
- # is the value paired with its key and the second is the remaining
50
- # hash of options passed to +render+.
47
+ # Adds a new renderer to call within controller actions. A renderer is invoked
48
+ # by passing its name as an option to AbstractController::Rendering#render. To
49
+ # create a renderer pass it a name and a block. The block takes two arguments,
50
+ # the first is the value paired with its key and the second is the remaining
51
+ # hash of options passed to `render`.
51
52
  #
52
53
  # Create a csv renderer:
53
54
  #
54
- # ActionController::Renderers.add :csv do |obj, options|
55
- # filename = options[:filename] || 'data'
56
- # str = obj.respond_to?(:to_csv) ? obj.to_csv : obj.to_s
57
- # send_data str, type: Mime[:csv],
58
- # disposition: "attachment; filename=#{filename}.csv"
59
- # end
55
+ # ActionController::Renderers.add :csv do |obj, options|
56
+ # filename = options[:filename] || 'data'
57
+ # str = obj.respond_to?(:to_csv) ? obj.to_csv : obj.to_s
58
+ # send_data str, type: Mime[:csv],
59
+ # disposition: "attachment; filename=#{filename}.csv"
60
+ # end
60
61
  #
61
- # Note that we used Mime[:csv] for the csv mime type as it comes with \Rails.
62
+ # Note that we used [Mime](:csv) for the csv mime type as it comes with Rails.
62
63
  # For a custom renderer, you'll need to register a mime type with
63
- # <tt>Mime::Type.register</tt>.
64
+ # `Mime::Type.register`.
64
65
  #
65
66
  # To use the csv renderer in a controller action:
66
67
  #
67
- # def show
68
- # @csvable = Csvable.find(params[:id])
69
- # respond_to do |format|
70
- # format.html
71
- # format.csv { render csv: @csvable, filename: @csvable.name }
68
+ # def show
69
+ # @csvable = Csvable.find(params[:id])
70
+ # respond_to do |format|
71
+ # format.html
72
+ # format.csv { render csv: @csvable, filename: @csvable.name }
73
+ # end
72
74
  # end
73
- # end
74
75
  def self.add(key, &block)
75
76
  define_method(_render_with_renderer_method_name(key), &block)
76
77
  RENDERERS << key.to_sym
@@ -80,7 +81,7 @@ module ActionController
80
81
  #
81
82
  # To remove a csv renderer:
82
83
  #
83
- # ActionController::Renderers.remove(:csv)
84
+ # ActionController::Renderers.remove(:csv)
84
85
  def self.remove(key)
85
86
  RENDERERS.delete(key.to_sym)
86
87
  method_name = _render_with_renderer_method_name(key)
@@ -92,39 +93,39 @@ module ActionController
92
93
  end
93
94
 
94
95
  module ClassMethods
95
- # Adds, by name, a renderer or renderers to the +_renderers+ available
96
- # to call within controller actions.
96
+ # Adds, by name, a renderer or renderers to the `_renderers` available to call
97
+ # within controller actions.
97
98
  #
98
99
  # It is useful when rendering from an ActionController::Metal controller or
99
100
  # otherwise to add an available renderer proc to a specific controller.
100
101
  #
101
- # Both ActionController::Base and ActionController::API
102
- # include ActionController::Renderers::All, making all renderers
103
- # available in the controller. See Renderers::RENDERERS and Renderers.add.
102
+ # Both ActionController::Base and ActionController::API include
103
+ # ActionController::Renderers::All, making all renderers available in the
104
+ # controller. See Renderers::RENDERERS and Renderers.add.
104
105
  #
105
- # Since ActionController::Metal controllers cannot render, the controller
106
- # must include AbstractController::Rendering, ActionController::Rendering,
107
- # and ActionController::Renderers, and have at least one renderer.
106
+ # Since ActionController::Metal controllers cannot render, the controller must
107
+ # include AbstractController::Rendering, ActionController::Rendering, and
108
+ # ActionController::Renderers, and have at least one renderer.
108
109
  #
109
- # Rather than including ActionController::Renderers::All and including all renderers,
110
- # you may specify which renderers to include by passing the renderer name or names to
111
- # +use_renderers+. For example, a controller that includes only the <tt>:json</tt> renderer
112
- # (+_render_with_renderer_json+) might look like:
110
+ # Rather than including ActionController::Renderers::All and including all
111
+ # renderers, you may specify which renderers to include by passing the renderer
112
+ # name or names to `use_renderers`. For example, a controller that includes only
113
+ # the `:json` renderer (`_render_with_renderer_json`) might look like:
113
114
  #
114
- # class MetalRenderingController < ActionController::Metal
115
- # include AbstractController::Rendering
116
- # include ActionController::Rendering
117
- # include ActionController::Renderers
115
+ # class MetalRenderingController < ActionController::Metal
116
+ # include AbstractController::Rendering
117
+ # include ActionController::Rendering
118
+ # include ActionController::Renderers
118
119
  #
119
- # use_renderers :json
120
+ # use_renderers :json
120
121
  #
121
- # def show
122
- # render json: record
122
+ # def show
123
+ # render json: record
124
+ # end
123
125
  # end
124
- # end
125
126
  #
126
- # You must specify a +use_renderer+, else the +controller.renderer+ and
127
- # +controller._renderers+ will be <tt>nil</tt>, and the action will fail.
127
+ # You must specify a `use_renderer`, else the `controller.renderer` and
128
+ # `controller._renderers` will be `nil`, and the action will fail.
128
129
  def use_renderers(*args)
129
130
  renderers = _renderers + args
130
131
  self._renderers = renderers.freeze
@@ -132,11 +133,11 @@ module ActionController
132
133
  alias use_renderer use_renderers
133
134
  end
134
135
 
135
- # Called by +render+ in AbstractController::Rendering
136
- # which sets the return value as the +response_body+.
136
+ # Called by `render` in AbstractController::Rendering which sets the return
137
+ # value as the `response_body`.
137
138
  #
138
- # If no renderer is found, +super+ returns control to
139
- # <tt>ActionView::Rendering.render_to_body</tt>, if present.
139
+ # If no renderer is found, `super` returns control to
140
+ # `ActionView::Rendering.render_to_body`, if present.
140
141
  def render_to_body(options)
141
142
  _render_to_body_with_renderer(options) || super
142
143
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  module ActionController
4
6
  module Rendering
5
7
  extend ActiveSupport::Concern
@@ -10,8 +12,8 @@ module ActionController
10
12
  # Documentation at ActionController::Renderer#render
11
13
  delegate :render, to: :renderer
12
14
 
13
- # Returns a renderer instance (inherited from ActionController::Renderer)
14
- # for the controller.
15
+ # Returns a renderer instance (inherited from ActionController::Renderer) for
16
+ # the controller.
15
17
  attr_reader :renderer
16
18
 
17
19
  def setup_renderer! # :nodoc:
@@ -24,113 +26,139 @@ module ActionController
24
26
  end
25
27
  end
26
28
 
27
- # Renders a template and assigns the result to +self.response_body+.
29
+ # Renders a template and assigns the result to `self.response_body`.
30
+ #
31
+ # If no rendering mode option is specified, the template will be derived from
32
+ # the first argument.
33
+ #
34
+ # render "posts/show"
35
+ # # => renders app/views/posts/show.html.erb
36
+ #
37
+ # # In a PostsController action...
38
+ # render :show
39
+ # # => renders app/views/posts/show.html.erb
40
+ #
41
+ # If the first argument responds to `render_in`, the template will be rendered
42
+ # by calling `render_in` with the current view context.
43
+ #
44
+ # class Greeting
45
+ # def render_in(view_context)
46
+ # view_context.render html: "<h1>Hello, World</h1>"
47
+ # end
48
+ #
49
+ # def format
50
+ # :html
51
+ # end
52
+ # end
53
+ #
54
+ # render(Greeting.new)
55
+ # # => "<h1>Hello, World</h1>"
28
56
  #
29
- # If no rendering mode option is specified, the template will be derived
30
- # from the first argument.
57
+ # render(renderable: Greeting.new)
58
+ # # => "<h1>Hello, World</h1>"
31
59
  #
32
- # render "posts/show"
33
- # # => renders app/views/posts/show.html.erb
60
+ # #### Rendering Mode
34
61
  #
35
- # # In a PostsController action...
36
- # render :show
37
- # # => renders app/views/posts/show.html.erb
62
+ # `:partial`
63
+ # : See ActionView::PartialRenderer for details.
38
64
  #
39
- # If the first argument responds to +render_in+, the template will be
40
- # rendered by calling +render_in+ with the current view context.
65
+ # render partial: "posts/form", locals: { post: Post.new }
66
+ # # => renders app/views/posts/_form.html.erb
41
67
  #
42
- # ==== \Rendering Mode
68
+ # `:file`
69
+ # : Renders the contents of a file. This option should **not** be used with
70
+ # unsanitized user input.
43
71
  #
44
- # [+:partial+]
45
- # See ActionView::PartialRenderer for details.
72
+ # render file: "/path/to/some/file"
73
+ # # => renders /path/to/some/file
46
74
  #
47
- # render partial: "posts/form", locals: { post: Post.new }
48
- # # => renders app/views/posts/_form.html.erb
75
+ # `:inline`
76
+ # : Renders an ERB template string.
49
77
  #
50
- # [+:file+]
51
- # Renders the contents of a file. This option should <b>not</b> be used
52
- # with unsanitized user input.
78
+ # @name = "World"
79
+ # render inline: "<h1>Hello, <%= @name %>!</h1>"
80
+ # # => renders "<h1>Hello, World!</h1>"
53
81
  #
54
- # render file: "/path/to/some/file"
55
- # # => renders /path/to/some/file
82
+ # `:body`
83
+ # : Renders the provided text, and sets the content type as `text/plain`.
56
84
  #
57
- # [+:inline+]
58
- # Renders an ERB template string.
85
+ # render body: "Hello, World!"
86
+ # # => renders "Hello, World!"
59
87
  #
60
- # @name = "World"
61
- # render inline: "<h1>Hello, <%= @name %>!</h1>"
62
- # # => renders "<h1>Hello, World!</h1>"
88
+ # `:plain`
89
+ # : Renders the provided text, and sets the content type as `text/plain`.
63
90
  #
64
- # [+:body+]
65
- # Renders the provided text, and sets the content type as +text/plain+.
91
+ # render plain: "Hello, World!"
92
+ # # => renders "Hello, World!"
66
93
  #
67
- # render body: "Hello, World!"
68
- # # => renders "Hello, World!"
94
+ # `:html`
95
+ # : Renders the provided HTML string, and sets the content type as
96
+ # `text/html`. If the string is not `html_safe?`, performs HTML escaping on
97
+ # the string before rendering.
69
98
  #
70
- # [+:plain+]
71
- # Renders the provided text, and sets the content type as +text/plain+.
99
+ # render html: "<h1>Hello, World!</h1>".html_safe
100
+ # # => renders "<h1>Hello, World!</h1>"
72
101
  #
73
- # render plain: "Hello, World!"
74
- # # => renders "Hello, World!"
102
+ # render html: "<h1>Hello, World!</h1>"
103
+ # # => renders "&lt;h1&gt;Hello, World!&lt;/h1&gt;"
75
104
  #
76
- # [+:html+]
77
- # Renders the provided HTML string, and sets the content type as +text/html+.
78
- # If the string is not +html_safe?+, performs HTML escaping on the string
79
- # before rendering.
105
+ # `:json`
106
+ # : Renders the provided object as JSON, and sets the content type as
107
+ # `application/json`. If the object is not a string, it will be converted to
108
+ # JSON by calling `to_json`.
80
109
  #
81
- # render html: "<h1>Hello, World!</h1>".html_safe
82
- # # => renders "<h1>Hello, World!</h1>"
110
+ # render json: { hello: "world" }
111
+ # # => renders "{\"hello\":\"world\"}"
83
112
  #
84
- # render html: "<h1>Hello, World!</h1>"
85
- # # => renders "&lt;h1&gt;Hello, World!&lt;/h1&gt;"
113
+ # `:renderable`
114
+ # : Renders the provided object by calling `render_in` with the current view
115
+ # context. The response format is determined by calling `format` on the
116
+ # renderable if it responds to `format`, falling back to `text/html` by
117
+ # default.
86
118
  #
87
- # [+:json+]
88
- # Renders the provided object as JSON, and sets the content type as
89
- # +application/json+. If the object is not a string, it will be converted
90
- # to JSON by calling +to_json+.
119
+ # render renderable: Greeting.new
120
+ # # => renders "<h1>Hello, World</h1>"
91
121
  #
92
- # render json: { hello: "world" }
93
- # # => renders "{\"hello\":\"world\"}"
94
122
  #
95
123
  # By default, when a rendering mode is specified, no layout template is
96
124
  # rendered.
97
125
  #
98
- # ==== Options
126
+ # #### Options
99
127
  #
100
- # [+:assigns+]
101
- # Hash of instance variable assignments for the template.
128
+ # `:assigns`
129
+ # : Hash of instance variable assignments for the template.
102
130
  #
103
- # render inline: "<h1>Hello, <%= @name %>!</h1>", assigns: { name: "World" }
104
- # # => renders "<h1>Hello, World!</h1>"
131
+ # render inline: "<h1>Hello, <%= @name %>!</h1>", assigns: { name: "World" }
132
+ # # => renders "<h1>Hello, World!</h1>"
105
133
  #
106
- # [+:locals+]
107
- # Hash of local variable assignments for the template.
134
+ # `:locals`
135
+ # : Hash of local variable assignments for the template.
108
136
  #
109
- # render inline: "<h1>Hello, <%= name %>!</h1>", locals: { name: "World" }
110
- # # => renders "<h1>Hello, World!</h1>"
137
+ # render inline: "<h1>Hello, <%= name %>!</h1>", locals: { name: "World" }
138
+ # # => renders "<h1>Hello, World!</h1>"
111
139
  #
112
- # [+:layout+]
113
- # The layout template to render. Can also be +false+ or +true+ to disable
114
- # or (re)enable the default layout template.
140
+ # `:layout`
141
+ # : The layout template to render. Can also be `false` or `true` to disable or
142
+ # (re)enable the default layout template.
115
143
  #
116
- # render "posts/show", layout: "holiday"
117
- # # => renders app/views/posts/show.html.erb with the app/views/layouts/holiday.html.erb layout
144
+ # render "posts/show", layout: "holiday"
145
+ # # => renders app/views/posts/show.html.erb with the app/views/layouts/holiday.html.erb layout
118
146
  #
119
- # render "posts/show", layout: false
120
- # # => renders app/views/posts/show.html.erb with no layout
147
+ # render "posts/show", layout: false
148
+ # # => renders app/views/posts/show.html.erb with no layout
121
149
  #
122
- # render inline: "<h1>Hello, World!</h1>", layout: true
123
- # # => renders "<h1>Hello, World!</h1>" with the default layout
150
+ # render inline: "<h1>Hello, World!</h1>", layout: true
151
+ # # => renders "<h1>Hello, World!</h1>" with the default layout
124
152
  #
125
- # [+:status+]
126
- # The HTTP status code to send with the response. Can be specified as a
127
- # number or as the status name in Symbol form. Defaults to 200.
153
+ # `:status`
154
+ # : The HTTP status code to send with the response. Can be specified as a
155
+ # number or as the status name in Symbol form. Defaults to 200.
128
156
  #
129
- # render "posts/new", status: 422
130
- # # => renders app/views/posts/new.html.erb with HTTP status code 422
157
+ # render "posts/new", status: 422
158
+ # # => renders app/views/posts/new.html.erb with HTTP status code 422
131
159
  #
132
- # render "posts/new", status: :unprocessable_entity
133
- # # => renders app/views/posts/new.html.erb with HTTP status code 422
160
+ # render "posts/new", status: :unprocessable_entity
161
+ # # => renders app/views/posts/new.html.erb with HTTP status code 422
134
162
  #
135
163
  #--
136
164
  # Check for double render errors and set the content_type after rendering.
@@ -140,7 +168,7 @@ module ActionController
140
168
  end
141
169
 
142
170
  # Similar to #render, but only returns the rendered template as a string,
143
- # instead of setting +self.response_body+.
171
+ # instead of setting `self.response_body`.
144
172
  #--
145
173
  # Override render_to_string because body can now be set to a Rack body.
146
174
  def render_to_string(*)