Skip to content
Browse files

When using an existing scope, it should be merged properly to the cla…

…ss. May fix ryanb/cancan#328 :)
  • Loading branch information...
1 parent 81f00f9 commit a10243a5691e29f801b6777d443de33ffb18a345 @flop flop committed Apr 1, 2011
View
2 lib/cancan/model_adapters/active_record_adapter.rb
@@ -87,7 +87,7 @@ def joins
def database_records
if override_scope
- override_scope
+ @model_class.scoped.merge(override_scope)
elsif @model_class.respond_to?(:where) && @model_class.respond_to?(:joins)
@model_class.where(conditions).joins(joins)
else
View
2 spec/cancan/model_adapters/active_record_adapter_spec.rb
@@ -125,7 +125,7 @@
Article.accessible_by(@ability).should == [article1]
end
- it "should only fetch associated records for nested controllers" do
+ it "should fetch only associated records when using with a scope for conditions" do
@ability.can :read, Article, Article.where(:secret => true)
category1 = Category.create!(:visible => false)
category2 = Category.create!(:visible => true)

0 comments on commit a10243a

Please sign in to comment.
Something went wrong with that request. Please try again.