Skip to content

Commit

Permalink
This fixes an odd error I was seeing in development mode when cache_c…
Browse files Browse the repository at this point in the history
…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 = current_user.photos.find(1) # 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
mphalliday authored and ryanb committed Nov 12, 2010
1 parent f901c36 commit 79180de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cancan/can_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def matches_subject?(subject)
end

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)) }
end

def matches_conditions_hash?(subject, conditions = @conditions)
Expand Down

0 comments on commit 79180de

Please sign in to comment.