How did the class method call on ActiveRecord::Relation takes a context?-Collection of common programming errors

This works because returned object (AR::Relation) accepts 3 kind of methods:

1) AR::Relation ‘native’ methods like :where, :includes, :joins, :limit, etc…

2) Enumerable methods. Most of them delegated to scoped collection, which is Array.

3) Other methods: delegated to base class through ‘method_missing

So, API documentation in that part (chaining with class methods) is wrong 🙂

Originally posted 2013-11-10 00:13:08.