ernie/squeel — Issue #73: Select fails when used directly on an association
Author: dvandersluis
Created: 2011-10-27 23:03:01+00:00
State: open

While using a Squeel'd `select` works fine when working directly with a model:

Permission.select{ permission_type_id }
> [#, #, ... ]

The same does not work when run through an association:

# assuming has_many :permissions on User
u = User.last
u.permissions.select{ permission_type_id }
> NameError: undefined local variable or method `permission_type_id' for main:Object

However, if I call `where` first, even with an empty block, it works again:

u.permissions.where{}.select{ permission_type_id }
> [#]

The same behaviour exists for a `has_and_belongs_to_many` association as well. I am using the 0.9.3 gem.