Forum: Ruby on Rails MVC and cron jobs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eb159164502bc1e2efb75ca7172805a0?d=identicon&s=25 Jeffrey L. Taylor (Guest)
on 2006-05-22 18: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.

TIA,
  Jeffrey
6ef8cb7cd7cd58077f0b57e4fa49a969?d=identicon&s=25 Brian Hogan (Guest)
on 2006-05-22 18: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.