moonshadow wrote:
> Hi all,
> 
> ROR newbie coming from a PHP background here.
> 
> I have a model that inherits from ActiveRecord::Base. I would like to
> extend that into two further models, to separate functionality from
> each other. Basically:
> 
> class Person < ActiveRecord::Base
>   attr_accessible :gender
> end
> 
> class Male < Person
> 
> end
> 
> class Female < Person
> 
> end
> 
> How can I write a method within Person that will detect what gender
> has been defined and return the proper object based on it?

You probably want to use single-table inheritance (STI) for this.  Read 
the ActiveRecord docs on this point.

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