rubyonrailsin

A Ruby and Rails talk

Tuesday, March 30, 2010


[Rails] Inheritance

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

I've done some reading on Single Table Inheritance.

I think I need something a little more though.

Classic example.

class Animal < ActiveRecord::Base
// db fields:
name: string
age: int
type: string
breed: string
end

class Feline < Animal
// db fields:
whisker_count: int
end

class Canine < Animal
// db fields:
seeing_eye_dog: boolean
end

So how do Canine and Feline inherit the fields from Animal although
they don't require each others fields. Does the Animals table just
contain all the fields but value can be null and only returns the
available fields for that Model?

Cheers,

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive