Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Refactor render_to_string so it's a little shorter and simpler. #10023

Closed
wants to merge 1 commit into from

3 participants

@orend

No description provided.

@steveklabnik
Collaborator

I'm going to make a judgement call here: we don't normally accept 'cosmetic' changes, and these 'refactorings' are so small that I don't think it's worth changing the history for. If they were part of larger changes, they'd be fine, but by themselves, it's not enough.

Thank you for your contribution, though! I'm sorry I can't accept it. :heart:.

@jeremy
Owner

@orend trouble is, response_body is only guaranteed to respond to #each, not all of Enumerable :grin:

@orend

@jeremy :-o
@steveklabnik no worries. Thanks for taking the time to explain the policy. I'll know for next (correct!) PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 4 deletions.
  1. +2 −4 actionpack/lib/action_controller/metal/rendering.rb
View
6 actionpack/lib/action_controller/metal/rendering.rb
@@ -6,7 +6,7 @@ module Rendering
# Before processing, set the request formats in current controller formats.
def process_action(*) #:nodoc:
- self.formats = request.formats.map { |x| x.ref }
+ self.formats = request.formats.map(&:ref)
super
end
@@ -21,9 +21,7 @@ def render(*args) #:nodoc:
# Overwrite render_to_string because body can now be set to a rack body.
def render_to_string(*)
if self.response_body = super
- string = ""
- response_body.each { |r| string << r }
- string
+ response_body.each_with_object("") { |r, string| string << r }
end
ensure
self.response_body = nil
Something went wrong with that request. Please try again.