Trying to replace some .find calls with better code

Hi all,

This forum has been very helpful in the past so I figured I'd try and
ask for some help on some (yet again) rather "newbie" stuff again.

I currently have the following DB Schema (Two Tables Listed here):

Users Table (user has_many children)

How about looking into named_scope.

in your Child model:

named_scope :lost,
                     :conditions => "is_lost = 't'"

You can then do this:

@user = User.find_by_login(params[:id])
@lost_children = @user.children.lost


Forgot to mention that named_scope is native Rails 2.1 or

If you're using an earlier version, you'll need to install the
has_finder plugin.


  @lost_children = {|c| c.is_lost}