Forum: Ruby on Rails Automated operations on a database

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.
Sonny C. (Guest)
on 2007-05-24 01:55
Hello, i have a question about a problem i can't figure out how to

I have a standard RoR application made with the classic MVC model, and I
need to (for example) edit a value in a table with a time-based rule.


starting table:

user    |   money
john    |    500

after 1 minute:

user    |   money
john    |    510


How to do that?
Really thank you.
David R. (Guest)
on 2007-05-24 02:39
(Received via mailing list)
I don't know if there's a more Rails or Ruby way to do this, but the
best I've done is write a ruby script that bootstraps Rails, get my
work done through ActiveRecord (so I don't by pass any of my business
logic), and then tell cron to run this script every so often.

The following code works for me in bootstrapping Rails:

#!/usr/bin/env ruby

# Ensure the environment was specified
if ARGV.length != 1
  puts "usage: ruby dummy_records.rb <rails_env>"
  exit 1

$LOAD_PATH << File.expand_path(File.dirname(__FILE__))


require 'rubygems'
require File.dirname(__FILE__) + '/../config/boot'
require "#{RAILS_ROOT}/config/environment"

def connect(environment)
  conf = YAML::load( + '/../config/

# Open ActiveRecord connection

# Enter code here to interact with your models.

Warm regards,

David R.

On May 23, 10:55 pm, Sonny C. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.