Skip to content
This repository
Browse code

Fix AC::Metal#response_body= to store same value on Ruby 1.8 and 1.9

This was because String#respond_to?(:each) differs in 1.8 and 1.9
  • Loading branch information...
commit cc3e738d89cc5a433473559c3f70e98c08f646de 1 parent b454601
Akira Matsuda amatsuda authored

Showing 1 changed file with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. +7 1 actionpack/lib/action_controller/metal.rb
8 actionpack/lib/action_controller/metal.rb
@@ -182,7 +182,13 @@ def status=(status)
182 182 end
183 183
184 184 def response_body=(val)
185   - body = val.nil? ? nil : (val.respond_to?(:each) ? val : [val])
  185 + body = if val.is_a?(String)
  186 + [val]
  187 + elsif val.nil? || val.respond_to?(:each)
  188 + val
  189 + else
  190 + [val]
  191 + end
186 192 super body
187 193 end
188 194

0 comments on commit cc3e738

Please sign in to comment.
Something went wrong with that request. Please try again.