Sunday, May 19, 2013

Re: [Rails] Make a column data unique for each user_id

On Sat, May 18, 2013 at 8:14 AM, Denny Mueller <macdankk@googlemail.com> wrote:
> 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?

> customer | customernumber | user_id
> 1 0001 1
> 2 0002 1
> 3 0001 2
> 4 0001 3
> 5 0002 3

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCvXDs86nz5%2BYgrpaaDqEbOvVRLcWx%3DQbioNhyeJPh7pg%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate