Newbie question

Hey all,

I've been working with rails for a grand total of 8 hours, and have
up against the first problem I haven't been able to adequately solve
using google.

So I've got a schema that basically consists of a bunch of
Each researcher has only one notebook. I'm trying to ensure that only
one notebook can be created for each user. Below is the code I've been
using in the create method for my notebook:

existingbook = Notebook.find(:first, params[:researcher_id])

This doesn't find a notebook with the specified researcher_id. It just
finds a notebook (and thinking about it, how could Notebook.find know
that the parameter you were giving it was a researched_id and not
something else?_

If you check log/development.log while you're doing this you can see
the sql queries generated which would reveal this.

What you probably meant to write is
Notebook.find_by_researcher_id(params[:researcher_id]) or if you
wanted to be long winded

Notebook.find :first, :conditions => ["researcher_id = ?",

Lastly, take a look at validates_uniqueness_of and be aware of the
race condition inherent in the way it works (your code suffers from
the same problem)