I'm getting the following failure when running rspec on the gem project:
1) CanCan::ModelAdapters::ActiveRecordAdapter should fetch only associated records when using with a scope for conditions
Failure/Error: category1.articles.accessible_by(@ability).should == [article1]
expected: [#<Article id: 1, name: nil, published: nil, secret: true, priority: nil, category_id: 1>],
got:  (using ==)
@@ -1,2 +1,2 @@
-[#<Article id: 1, name: nil, published: nil, secret: true, priority: nil, category_id: 1>]
The reason for this error is that with_model version 2.x creates a subclass of the ActiveRecord model you're defining. This results in the Rule.relevant? method having trouble identifying which rules apply to the model.
Version 1.x of with_model doesn't have this issue.
use version 1.x of with_model to avoid errors in class comparisons
Merge pull request #476 from kirkconnell/with_model-version-fix
Specs fail when running in a freshly installed environment.
What were the errors you were seeing? I'm the maintainer of with_model and I'd like to fix them if the problem is on our end.
It was a strange thing. Nested models ended up with a different class object id than their original class. To better explain this, supposed you had models Author and Book. In Author we had a has_many :books association. The problem was that the result of author.books.first.class.object_id == Book.object_id was false. This made a couple of specs to fail since they were comparing object arrays.
author.books.first.class.object_id == Book.object_id
I ran into something similar earlier. I'm going to work out a minimal test case and see what I can do.
I fixed the issue in with_model. Pull request at #505