Permalink
Browse files

checks if active record responds to 'joins', so this can work with in…

…ternuity's quick_scopes gem; added .swp files to git ignore
  • Loading branch information...
1 parent 79180de commit cf263c105d953047240f056acc977ff10fdca648 @ramontayag ramontayag committed with Nov 2, 2010
Showing with 3 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +1 −1 lib/cancan/active_record_additions.rb
View
@@ -1,3 +1,5 @@
+*.swp
+**/*.swp
*.gem
Gemfile.lock
.bundle
@@ -21,7 +21,7 @@ module ClassMethods
# internally uses Ability#conditions method, see that for more information.
def accessible_by(ability, action = :read)
query = ability.query(action, self)
- if respond_to? :where
+ if respond_to?(:where) && respond_to?(:joins)
where(query.conditions).joins(query.joins)
else
scoped(:conditions => query.conditions, :joins => query.joins)

0 comments on commit cf263c1

Please sign in to comment.