Skip to content

Commit 4920e15

Browse files
committed
For Rails < 2.3 need to probe for empty? method to distinguish a collection proxy from other relations.
1 parent 625e7fe commit 4920e15

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/declarative_authorization/authorization.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ def validate? (attr_validator, object = nil, hash = nil)
512512
object ||= attr_validator.object
513513
return false unless object
514514

515-
if Authorization.is_a_association_proxy?(object)
515+
if ( Authorization.is_a_association_proxy?(object) &&
516+
object.respond_to?(:empty?) )
516517
return false if object.empty?
517518
object.each do |member|
518519
return true if validate?(attr_validator, member, hash)

0 commit comments

Comments
 (0)