K
K
Kasheftin2011-04-15 17:51:24
Ruby on Rails
Kasheftin, 2011-04-15 17:51:24

Heavy scripting and ruby ​​on rails?

Absolute newbie in rails.
I am writing a website. List of articles. Then I write a script like a new article grabber or an indexer.
What is the best way to write it? Now this is a ruby ​​script that runs from cron and runs for half an hour. This is theoretically incorrect. I would like to use models from rails, validators, automatically add data to related models. Does this mean that you need to connect the entire framework and write everything through rails?
Where are updates and other scripts written in rails? If, for example, there are a bunch of small scripts running frequently, it's not practical for everyone to run their own rails environment.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Shaydurov, 2011-04-15
@GearHead

there are quite a few schedulers written for rails. the general principle of working with them: install the gem, specify the launch settings in the initializer, and then write the tasks themselves completely in the rails scope (with activerecord and other goodies). For more details
, you can look at this:
backgroundrb.rubyforge.org/github.com/tobi/delayed_job
github.com/javan/whenever

S
sl_bug, 2011-04-15
@sl_bug

app/models/my_model.rb:
class MyModel
def self.some_updater
#do something
end
end
run
rails runner MyModel.some_updater

M
Magot, 2011-04-15
@Magot

About DelayedJob, as always good, on Railscasts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question