Browse files

This fixes an odd error I was seeing in development mode when cache_c…

…lasses = false (the default), specifically when loading an object throught the parent in load_and_authorize_resource.

Assume Photo model and User model where user has many photos:

@photo = # this returns a photo
@photo1 = Photo.find(1)

@photo.kind_of?(Photo) is not always true for some reason when class_cacheing is false.  Where as @photo1.kind_of?(Photo) always appears to be true.  Of interesting note, in the above example @photo != @photo1 if kind_of? is false.  Very odd.
Again, this only appears to be when loading and object through an association.
  • Loading branch information...
1 parent f901c36 commit 79180de3722673388c1eb65fc09db5a72fe0b1a8 @mphalliday mphalliday committed with Oct 17, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/cancan/can_definition.rb
@@ -97,7 +97,7 @@ def matches_subject?(subject)
def matches_subject_class?(subject)
- @subjects.any? { |sub| sub.kind_of?(Module) && (subject.kind_of?(sub) || subject.kind_of?(Module) && subject.ancestors.include?(sub)) }
+ @subjects.any? { |sub| sub.kind_of?(Module) && (subject.kind_of?(sub) || subject.class.to_s == sub.to_s || subject.kind_of?(Module) && subject.ancestors.include?(sub)) }
def matches_conditions_hash?(subject, conditions = @conditions)

0 comments on commit 79180de

Please sign in to comment.