Gabriel Saravia wrote:
> 
> 
> 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.

Thanks Gabriel, but unfortunately this exact solution wouldn't work in 
our case. The names of the various Wheel tables are not known at design 
time. In other words, there's nothing to stop someone creating a new 
table and adding it to the mapping table during runtime.

Given the wonderful dynamic nature of ruby I suppose I could get past 
that fairly easily by creating the Wheel subclasses dynamically, but I'm 
not sure that that is the best approach.

-- 
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