binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.39k stars 134 forks source link

Does not work with virtual attributes #41

Open hgujral opened 15 years ago

hgujral commented 15 years ago

Ben seems to show examples of "User.age_greater_than(20)" but age as an attribute is often used in models as a virtual attribute which calculates the current age from DOB.

When I use age as a virtual attribute and search on it, I get a "undefined method `age_greater_than' for #Class:0x48fff80"

What am I missing?

Mange commented 15 years ago

Searchlogic only generates ActiveRecord conditions as named scopes. Since your RDBMS does not know about the virtual attributes, this is impossible. Create your own named_scope, if neccessary, where you create the condition required for this to work.