Forum: Ruby on Rails MVC and cron jobs

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jeffrey L. Taylor (Guest)
on 2006-05-22 20:03
(Received via mailing list)
I have a cronjob that runs "ruby script/runner 'Channel.preload'".
Channel is a parent model, Item is the child model (i.e., Channel
has_many :items and Item belongs_to :channel).  The coupling is
minimized, the coherence looks good, but I'm not sure the model is the
right place to put this code.  Is there a better place to put this
code, e.g., a component (I don't really understand components and
attempts to use them haven't worked as expected/advertised).  The code
could go in a module, i.e., all the added code is class methods.

Brian H. (Guest)
on 2006-05-22 20:18
(Received via mailing list)
Without knowing what you're doing, it looks fine.  Script/runner is
going to give you access to anything in your rails application so what
you're doing should be fine.

However, my solution was to create a class called 'Run'  and put all
of the commands that would be called from outside of the web app in
that class.  It helped me keep things organized a bit better.
This topic is locked and can not be replied to.