geekq/workflow — pull request #90 by jamezilla (2013-08-02 03:09:48+00:00)
Title: workaround for activerecord bug with automatic state scopes. 

I'm running a project with Rails 3.2.11 and ruby 1.9.3p448 and there's a bug in its version of ActiveRecord which causes Arel to blow up when you use the automatically generated workflow scopes.

For example:
```
[36] pry(main)> Loan.with_checked_out_state.all
TypeError: Cannot visit Workflow::State
from /Users/james/.rvm/gems/ruby-1.9.3-p448@checkout/gems/arel-3.0.2/lib/arel/visitors/visitor.rb:25:in `rescue in visit'
```

This patch solved the problem for me. It seems to behave slightly differently in that it doesn't return a relation, but I confirmed it is chainable with other Active Record query interface methods. It should be drop in compatible.

Confirmed that it works with rails 3.2.14.