Re: Design question

Ar Chron
Tue, 18 May 2010 13:26:46 -0000

pepe wrote:
>
> I have thought about factoring out the name to a separate model:
>

Most of this decision depends on how you intend to treat your Users and
Customers. Perhaps you just have people, with a flag attribute on each,
or people with related models of Customer-specific info and
User-specific info. Is a User really different from a Person (will you
track people who aren''t users or customers - if so, then Person
isn''t
abstract)? But only you know the answers to these questions.

I think of names (first, last, middle, full, nickname, etc) as
attributes of some model, not a model of its own...

Sounds like you *could* have a base (abstract) class of Person, then do

class Person < ActiveRecord::Base
  self.abstract_class = true
  # common methods go here
end

class User < Person
  # User table has all the fields it needs
  # User specific methods go here
  blah blah blah

end

class Customer < Person
  # Customer table has all the fields it needs
  # Customer specific methods go here
  blah blah blah
end

if Users and Customers really, really are different entities.

You could also go the STI route...
--
Posted via http://www.ruby-forum.com/.