diff options
Diffstat (limited to 'actionpack/lib/action_view/render')
-rw-r--r-- | actionpack/lib/action_view/render/layouts.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/rendering.rb | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/render/layouts.rb b/actionpack/lib/action_view/render/layouts.rb index b4720aa681..c790a70b3e 100644 --- a/actionpack/lib/action_view/render/layouts.rb +++ b/actionpack/lib/action_view/render/layouts.rb @@ -51,7 +51,7 @@ module ActionView if formats.size == 1 _find_layout(layout) else - update_details(:formats => self.formats[0,1]){ _find_layout(layout) } + update_details(:formats => self.formats.first){ _find_layout(layout) } end rescue ActionView::MissingTemplate => e update_details(:formats => nil) do diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index b0fed556c3..a8f745afd1 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -21,7 +21,7 @@ module ActionView _render_partial(options) else template = _determine_template(options) - self.formats = template.formats + _freeze_formats(template.formats) _render_template(template, options[:layout], options) end when :update @@ -58,12 +58,18 @@ module ActionView content = template.render(self, locals) { |*name| _layout_for(*name) } @_content_for[:layout] = content - if layout - content = _render_layout(layout, locals) - end - + content = _render_layout(layout, locals) if layout content end end + + # Freeze the current formats in the lookup context. By freezing them, you are guaranteeing + # that next template lookups are not going to modify the formats. The controller can also + # use this, to ensure that formats won't be further modified (as it does in respond_to blocks). + def _freeze_formats(formats) #:nodoc: + return if self.formats.frozen? + self.formats = formats + self.formats.freeze + end end end |