Cris S. wrote:
Hi Marnen.
Thanks for your reply. Here is what I am trying to do…
We are trying to use mongrel as a job execution engine and use rails for
the front end GUI.
I’m not sure I understand. Mongrel is just a Web server. Are you
saying you have a Rails app that calls other processes?
We intend to have an initial configuration screen
where the administrator will populate various properties in form for use
in determine how the various jobs will run. Whenever the ‘system’ (and
system will consist of more than, but include, mongrel) is brought down
for maintenance we want the admins to reexamine these properties so we
want them ‘forgotten’ between maintenance windows. Scalability is not
an issue here as only a handful of admins will use the tool, (thus no
clustering will be involved) and I expect statics will work.
Again: they’re not called that in Ruby. This isn’t Java.
In fact,
when I moved the TransientData class to a file called library.pl
Did you mean library.rb ? (Anyway, it should be in a file called
transient_data.rb for clarity.)
in the
lib directory and required it in the controller it did (finally) work.
That makes some sense, I suppose…
If the right approach is to use an active record, despite the lack of
need for persistence, can one create an active record and declare it to
be a singleton (i.e. never more than one row in the database)? Can one
do the equivalent of a j2ee startup bean and have a mongrel run a job
upon startup of the server so I could delete that singleton? The idea
of being able to use an active record and have all of the validation
goodies does appeal to me.
You could do this (although there are a variety of reasons that
singletons are probably a bad idea), but if it’s just a question of
configuration parameters, it’s probably easier to read them from a YAML
file. There’s a Railscast on this topic.
If you really want them transient, though, there’s no need to store them
anywhere at all! Just call TransientData.new in the show action, not in
the constructor. Your controllers don’t need – and should not have –
constructor methods. Remember, this isn’t Java – instance variables
spring into existence whenever you mention them.
Thanks,
Cris
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]