Putting filter conditions on ActiveRecord::Base object?

Wes Gamble wrote:

Can I use an after_find callback to cull out the rows that I don't want?

-- Posted via http://www.ruby-forum.com/.

Take a look for with_scope...

_Kevin

Use acts_as_view (Google for it) - by maiha, author of scoping in the first place.

with_scope is going to be your best bet here. Apply the KISS rule liberally.

Erik

with_scope is going to be your best bet here. Apply the KISS rule liberally.

Erik

Actually, let me illustrate with a section of my own code:

(instance method of a Group model)   def members     User.with_scope :find => {:conditions => "#{User.table_name}.id != #{self.leader.id}"} do       users.find_all     end   end