Good day.
I want to run rb-script via Cron, for inseringt data in
database.
Is it possible using ActiveRecord, for accessing to DBMS. What
should I reguire in rb-file ?
Good day.
I want to run rb-script via Cron, for inseringt data in
database.
Is it possible using ActiveRecord, for accessing to DBMS. What
should I reguire in rb-file ?
On 14 Jul 2008, at 09:29, Falko wrote:
Good day.
I want to run rb-script via Cron, for inseringt data in
database.
Is it possible using ActiveRecord, for accessing to DBMS. What
should I reguire in rb-file ?
There are slightly different answers depending on what you want to do.
I’m assuming that you do want to use your app’s models (ie it’s not
just activerecord you want, you need to setup the environment
The easiest way is to use script/runner, which will setup the
environment for you. Failing that, requiring config/boot and config/
environment will load up the rails environment for you. (those aren’t
on the load path, so you’ll need something like require
File.dirname(FILE) + ‘/…/config/boot’ depending on where your
script is in relation to the rest of the app)
Fred
Falko wrote:
Good day.
I want to run rb-script via Cron, for inseringt data in
database.
Is it possible using ActiveRecord, for accessing to DBMS. What
should I reguire in rb-file ?
I’d suggest you may also want to make this script get run by a rake task
/lib/tasks/whatever.rake
desc “whatever you want”
task :something => :environment do
Call::The.code_you_want
end
then just get cron to call the rake command.
Falko wrote:
Good day.
I want to run rb-script via Cron, for inseringt data in
database.
Is it possible using ActiveRecord, for accessing to DBMS. What
should I reguire in rb-file ?
Hi,
require ‘rubygems’
require ‘active_record’
It’s all in the wiki:
http://wiki.rubyonrails.org/rails/pages/HowToUseActiveRecordOutsideRails
Fernando P. wrote:
require ‘rubygems’
require ‘active_record’It’s all in the wiki:
http://wiki.rubyonrails.org/rails/pages/HowToUseActiveRecordOutsideRails
although,
that will only get you ActiveRecord…
it won’t get you the connection setup in your database.yml,
or any of the subclasses of ActiveRecord::Base that you’ve set up in
your project.
Just depends what you’re trying to do.
Creating a rake task is the far best solution. You can access all your
Models ideal for cron jobs. I use this on one of my projects which
updates/add many models every night.
On Jul 14, 12:14 pm, Matthew R. Jacobs <rails-mailing-l…@andreas-
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs