Adding conditions to every find(:all) call

Alex

   > > with_scope(:find => { :conditions => ["bucket_id = ?",2] }) do
   > > ..
   > will that work for find_by_something or would you need methods
for that too?

As with_scope is on the deprecation path - in version 2.0 -, you
should consider replacing every
   Folder.find(:all)
call by a
   @my_folders = Folder.find(:all, :conditions => 'bucket_id = 123')

, that you can later as you would have used Folder.find(:all) :

So,
    Folder.find_by_name ('john')
becomes
    @my_folders.find_by_name ('john')

Alain

Justin

  > > @my_folders = Folder.find(:all, :conditions => 'bucket_id = 123')
  > > @my_folders.find_by_name ('john')
  > That seems very redundant and not DRY at all.

And also very wrong: this code doesn't work. My bad.

I misread the question and mis-reused the usual example of how to
replace with_scope :

   user = User.find(params[:id])
   user_articles = user.blog.articles

Alain

You sure that with_scope is on the deprecation path? Last I heard it was just being moved to protected, meaning it can only be used in models.

Brian

  > You sure that with_scope is on the deprecation path? Last I heard it was
  > just being moved to protected, meaning it can only be used in models.

You're right.

Alain