However this does not work because id method within but_not_itself
named_scope returns an Object.id (instance id) and not ActiveRecord id
(database id).
However this does not work because id method within but_not_itself
named_scope returns an Object.id (instance id) and not ActiveRecord id
(database id).
The reason this does not work is because that expression "id" is
evaluated when named_scope is call to create the scope, ie when the
class is loaded, so self is the class Contact.
It's the same reason why doing :conditions => ['created_at < ?',
1.day.ago] won't work properly: the 1.day.ago is evaluated once, at
class load time and then never again.
Luckily instead of passing a hash of options you can pass a lambda
that returns a hash of options. Since that proc will be called when
the scope is loaded and in the right context you should be fine.