# Model Design Question

**URL:** <https://www.ruby-forum.com/t/model-design-question/127760>\
**Category:** Rails\
**Created:** [February 1, 2008, 1:13am UTC](https://www.ruby-forum.com/t/model-design-question/127760 "2008-02-01T01:13:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roofjump](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@roofjump](https://www.ruby-forum.com/u/roofjump)\
**Post date:** [February 1, 2008, 1:13am UTC](https://www.ruby-forum.com/t/model-design-question/127760/1 "2008-02-01T01:13:25Z")

</div>

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
