Forum: Ruby on Rails Tips for Data Model

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
gil (Guest)
on 2008-12-11 10:27
(Received via mailing list)
I can't quite seem to get the data model down for a fairly simple set
of data.

The data is:

Framework --> Strand --> Level --> Benchmark

It would be simple enough if there were only three levels but since
there are four I can't use  straight has_many xyz :through clause.

The end goal is to have users be able to select a framework, then a
strand, then a level, then a benchmark.

Any help would be appreciated.
Patrick D. (Guest)
on 2008-12-11 15:15
(Received via mailing list)
I'm not sure I understand why the number of levels (3, 4, or 104) is an
issue.  So, perhaps I'm not understanding your question.  But why not:

class Framework < ActiveRecord::Base
  has_many :strands, :dependent => :destroy

class Strand < ActiveRecord::Base
  belongs_to :framework
  has_many :levels, :dependent => :destroy

class Level < ActiveRecord::Base
  belongs_to :strand
  has_many :benchmarks, :dependent => :destroy

class Benchmark < ActiveRecord::Base
  belongs_to :level

This topic is locked and can not be replied to.