Make a column data unique for each user_id

This is my setup. I have a table user where all user with password and so on
are set. The customer table has some customer related data. The user_id is
the foreign key to relate the customers to the user.

On of the column in the customer table is the customernumber. These numbers
has to be uniq for each user_id.

Is this a legacy database you're trying to use with Rails? It doesn't
appear to follow Rails conventions.

In this example, is "customer" a unique auto-generated identifier? If
so, why do you need "customernumber" to also be unique? If not,
what is it?