unique entries

You could try:

  validates_uniqueness_of :rentalcar_id, :scope => :airline_id

Whichever is the widest scope (e.g., can an airline have a lot of
rental cars? Or the other way around?) should probably go with
:scope. I don't _think_ it would affect anything, but for modeling's
sake it should be that way. :slight_smile:


I second that. I'm using validates_uniquemess_of with :scope for the
same purpose in one of my projects. In the testing I have done it did
not matter which one went in the :scope. I agree that the widest
would be the better choice for readability later.

Well, you can "say" it, but Ruby will parse that as:

validates_uniqueness_of(:rentalcar_id, :scope => :airline_id) and :_user_id

The "and" part is a no-op, which I'm guessing isn't what you intend.

If you want to use two columns for the scope, the syntax is:

:scope => [:airline_id, :user_id]

which is illustrated in the API docs for validates_uniqueness_of