I have a ThermalAnalysis class which is NOT a subclass of
ActiveRecord::Base. ThermalAnalysis has a dozen or so sub-classes. I
want to know the best places to put the files, and how to automatically
require all the subclass files.
Currently, I have:
app/models/
thermal_analysis.rb
app/models/thermal_analyses/
subclass1.rb
subclass2.rb
...
First, is it stylistically okay to put thermal_analysis.rb in the models
directory, considering that it's not an ActiveRecord model? (It IS
intimately tied to a few AR models.) If not in models, then where would
you suggest?
Second, what's the best technique for requiring all the ThermalAnalysis
subclasses? I could push a new value onto $LOAD_PATH from within
thermal_analysis.rb, as in:
$LOAD_PATH << File.expand_path("../thermal_analyses", __FILE__)
...but that will only get triggered when ThermalAnalysis is first
referenced, which is usually too late. (FWIW, ThermalAnalysis is
essentially an abstract class: only its subclasses get instantiated.)
TIA.
- ff
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment