I have got a Rails app running which displays data that is generated by some cronjobs. This app is hosted on an embedded device which hasn’t got that many ressources. I tested several methods of doing this the rails way. Each of them fails either because rails has to be loaded (too resource hungry) or mongrel is blocked while the cronjob is executed (calling wget on a action which does the job). As I am limited to one mongrel instance on this device, especially the wget-method is fatal.
So I discovered that it’s the most resource-efficient way to execute a native cronjob on the underlying *nix OS, and hand on the result to rails. At the moment this is done by writing data from the cronjobscript directly to a special “hand on”-table in the rails database.
So what to consider when writing to the database without using the “model” of rails? Any pitfalls? What about the updated_at field? Do I have to update the date to force rails to reload the data?
You need to make no special considerations in my opinion.
You don’t need to update the
updated_atcolumn for Rails to reload it. The decision to reload or not is entirely up to the Rails code. Rails needs to be able to cope with direct access to the database since this is a common method for clustering.