I have 37 different tables with each having its own sort column (sort
implying that the main data of that table is sorted on that particular
column). Each of these sort columns is different and unique.
To make things easier for myself I created an inheritance template where
each of the 37 tables inherits from one templated controller and one
templated model. They all use the same methods. So all 37
controllers/models are basically empty and the inherited/templated
controller and model contain the objects/methods.
I’m now creating a master table that needs to pull the data from each of
those 37 tables and the sort columns, perform calculations, and then
save the refined calculations back to itself (the master table).
I’m trying to figure out a proper way to setup the associations. All
I’m doing is gathering data from those tables to calculate further
values. My master data table belongs to my team model and the rest of
the data tables belong to my team model. The current associations are:
class Team < ActiveRecord::Base
class MasterTable < ActiveRecord::Base
class InheritanceTemplate < ActiveRecord::Base
self.abstract_class = true
class DataOne < InheritanceTemplate
class DataTwo < InheritanceTemplate
class DataThree < InheritanceTemplate
I’m not sure how the association should be setup between the Master
Table model and the Inheritance Template model. They both belong to
Assume that I want to retrieve the following:
I could do:
@one = DataOne.find(:all)
@two = DataTwo.find(:all)
@three = DataThree.find(:all)
and point to a custom method that searches for the specific column and
only returns results for that column but I figured there might be a
better approach to all of this.
Any help would be appreciative…