checks if active record responds to 'joins', so this can work with internuity's quick_scopes gem; added .swp files to git ignore

This commit is contained in:
Ramon Tayag 2010-11-02 10:57:45 +08:00 committed by Ryan Bates
parent 79180de372
commit cf263c105d
2 changed files with 3 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.swp
**/*.swp
*.gem
Gemfile.lock
.bundle

View File

@ -21,7 +21,7 @@ module CanCan
# 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)