Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Rails 4 fix for #951 #992

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cancan/model_adapters/active_record_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def joins

def database_records
if override_scope
@model_class.scoped.merge(override_scope)
@model_class.where(nil).merge(override_scope)
elsif @model_class.respond_to?(:where) && @model_class.respond_to?(:joins)
mergeable_conditions = @rules.select {|rule| rule.unmergeable? }.blank?
if mergeable_conditions
Expand All @@ -107,7 +107,7 @@ def database_records
@model_class.where(*(@rules.map(&:conditions))).joins(joins)
end
else
@model_class.scoped(:conditions => conditions, :joins => joins)
@model_class.all(:conditions => conditions, :joins => joins)
end
end

Expand Down