I've been working on something like this myself.  Depending on how 
different the two are, it may also just be easier to use Single Table 
Inheritance?

if you decide that abstract classes are better, then I suggest that you 
do something like this to make your life easier:

class Person < ActiveRecord::Base

TypesofPeople = ["Client", "Prospect"]


def self.abstract_find (person_type, *args)
  if TypesofPeople.include?(person_type)
    person_type.constantize.find(*args)
  else
    nil
  end
end

cheers,
-Gabe

Marnen Laibow-Koser wrote:
> Doug Jolley wrote:
>>> In Rails, a model normally maps to a table.
>> 
>> Yes; but, it appears that in this case it would be really nice if I
>> could have a single model and then somehow simply switch between
>> associated tables.  (I'm not sure that I'm going to be able to do it.)
> 
> Why not just subclass?
> 
> class Person < ActiveRecord::Base
>   self.abstract_class = true # this will prevent Rails from expecting a 
> "people" table
> 
>   # common features go here
> end
> 
> class Client < Person
>   ...
> end
> 
> class Prospect < Person
>   ...
> end
> 
> That should do the trick!
> 
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]

-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to