> Secondly, does anyone have any pointers on how I can make this work in
> Active Record in a nice clean way.

In a domain i'm workin in, this type of thing also came up, and I chose 
to split it in a somewhat similar way using abstract classes. Create an 
abstract class, Wheels, put all common code in there.  I chose to 
include the equivalent of that mapping table as a constant, so in your 
example a "CarToWheelsClassHash" Constant, and then create sub-classes 
for each of the wheels table.  Override the ActiveRecord Methods for the 
Wheel class, and then re-override them in the subclasses to bring them 
back.

Wheel < ActiveRecord::Base
  self.abstract_class = true

  CarToWheelsClassHash = {:ford => "FordWheel"}

  def self.abstract_find(car_brand, *normalfindargs)
    CarToWheelsClassHash[car_brand].constantize.find(*normalfindargs)
  end

  [other code common to all wheels models]
end

FordWheel < Wheel
  code specific to the ford wheels model
end

hope that makes sense to you, i actually really like this solution so 
far on my end.
-- 
Posted via http://www.ruby-forum.com/.

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

Reply via email to