Model Design Question

Hey all. I’m fairly new to Rails (and ORM for that matter) and have a
design question for you. I’m tasked with designing an app to do the
following:

  • System should be able to handle different types of “tests”
  • Each test has one more more Samples associated to it
  • The type of Test will drive what Samples are shown for user input

I’ve started down the “single table inheritance” path for the Test
model:

class Test < AR::Base
has_many :samples
end

class TestA < Test
#business logic for TestA
end

class TestB < Test
#business logic for TestB
end

For argument’s sake, lets say that a TestA has 2 samples. When a user
selects a TestA on a view, I need to nuke up a TestA for creation.
Since the business rule is to force the TestA to have 2 samples, when
should I do this in the model? Override the constructor for TestA and
call self.samples.add() twice? I really only want 1 complex form to
handle the creation of a new test and it’s samples.

Thanks for the help!

Geoff