best way to implement automatic with_scope for all find methods on an object

I have a situation where I need to have all find methods on a object
automatically scoped to a certain condition, ie

MyObject.with_scope( :find => { :conditions => "x = 'foo'" }) where
'foo' is something that is found in the user session.

obviously the model is not going to know anything about the session so
i can't do something like

class MyObject < ActiveRecord::Base

  alias_method :orig_find, :find
  def self.find(*args)
    with_scope { :find => { :conditions => ["x = ?", @current_user.x] })

(not even sure if that would be even close to how it MIGHT be implemented).

i other words, i want to get around having to do

mo = MyObject.find_by_x(x) or having to specify the conditions ALL the time

any assistance would be appreciated.


try the meantime_filter plugin

class BooksController < ApplicationController
  meantime_filter :scope_user
  def index; list; render :action=>'list'; end

  def list
    @books = Book.find(:all, :include=>[:user])

  def scope_user
    if logged_in?
         {:find=>{:conditions=>["ubooks.user_id = ?",]
}}, &block)
    else; yield; end