On 29 March 2010 10:43, Paritian Thakkar <[email protected]> wrote:
> Hello Friends,
>
> I am trying to define relationship between real-world entities in my
> application.... But I am feel, I am over-representing it a little and
> hence would like your opinion.
>
> class User < ActiveRecord::Base
>  has_and_belongs_to_many :user_groups
>
>  attr_accessible :username, :email, :password, :password_confirmation
>
> end
>
> class Customer < User
>  has_many :orders
>
>  belongs_to :person
> end
>
> class Employee < User
>  belongs_to :person
>
> end
>
> class Person < ActiveRecord::Base
>  has_many :addresses
> end
>
>
> Should I merge User and Person Models? Basically user has only login
> information while Person has details like first_name, last_name, address
> and so on....

Yes, why complicate matters.

Have you considered that a user might be both a customer and an
employee?  Your model would preclude that I think.  Are you sure it
would not be better just to have the user model who can be either or
both just by attribute contents?

Colin

>
> Also, should Customer and Employee inherit from Person or User? Trying
> to normalize stuff but dont want to over-normalize it too..
>
> Thank you.
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to