tchandy/octopus — pull request #267 by dontfidget (2014-08-30 04:46:07+00:00)
Title: make instances of Octopus::RelationProxy have class equality with ActiveRecord::Relation

I'm seeing a problem in Octopus where it cannot handle relations passed where an id is expected, such as this:

```ruby
Product.where(id: Product.on_sale)
```

Because of changes in rails, I believe Octopus::RelationProxy needs to respond true to both `relation.is_a?(ActiveRecord::Relation)` and `ActiveRecord::Relation === relation`. In current beta releases of rails it uses `is_a?` (see https://github.com/rails/rails/blob/8c52480ba6071a12b97f124d9f21df2c39df3ed3/activerecord/lib/active_record/relation/query_methods.rb#L1154):

```ruby
def add_relations_to_bind_values(attributes)
if attributes.is_a?(Hash)
attributes.each_value do |value|
if value.is_a?(ActiveRecord::Relation)
self.bind_values += value.bind_values
else
add_relations_to_bind_values(value)
end
end
end
```
In currently released rails versions, it uses `grep`, which just uses `===` (from https://github.com/rails/rails/blob/v4.1.5/activerecord/lib/active_record/relation/query_methods.rb#L937):

```ruby
values.grep(ActiveRecord::Relation) do |rel|
self.bind_values += rel.bind_values
end
```

This fix overrides `is_a?` on Octopus::RelationProxy and monkey-patches ActiveRecord::Relation so that it