Browse files

Prevent the silent destruction of user input

Rather than silently changing what was specified to be the collection for this partial,
this will call `to_ary` on whatever is passed.  This has a few benefits for the developer:

* Knowledge that the collection should implement `to_ary` if it doesn't.
* Principle of least surprise as, rather than the partial not being rendered at all, an exception gets raised.
  • Loading branch information...
1 parent bab3c7c commit 92f65180502f02fd97e0e5c351c6d0728d285509 @parndt committed Feb 22, 2015
Showing with 1 addition and 2 deletions.
  1. +1 −2 actionview/lib/action_view/renderer/partial_renderer.rb
@@ -400,8 +400,7 @@ def setup(context, options, block)
def collection_from_options
if @options.key?(:collection)
- collection = @options[:collection]
- collection.respond_to?(:to_ary) ? collection.to_ary : []
+ collection = @options[:collection].to_ary

0 comments on commit 92f6518

Please sign in to comment.