Hello,
I have table called ‘listings.’ There are a certain combination of
properties which make a listing viewable (e.g., it is confirmed, has
been authorized, hasn’t expired, etc.). Each listing has one and only
one category.
I want to be able to do things like Listing.find_viewable(…) and
Category.find(…).viewable_listings, but I see no way to do this
without violating DRY in several places, or stepping all over AR’s toes.
My idea was to define a method in application.rb which returns the
appropriate SQL string that makes a listing viewable, call it
viewable_sql, and then put that where appropriate. However, I’d like
find_viewable to work just like find, except that it would modify the
parameters to find to incorporate those conditions.
Any thoughts or examples of something similar?
Thanks.
–
Jesse F. [email protected]
University of Chicago - NSIT Web Services
AIM: farmerje
Jabber: [email protected]
Phone: (773)363-1058