I expect the problem is the path to the "chronic" code relative to script file. When you run irb paths are relative to the irb code location. When you run a script, paths are relative to the script file.
Try using this form of the require statement:
Code:
require File.dirname(__FILE__) + '/path/to/chronic'
The path to chronic needs to be relative to the script file.
Or you could use the absolute path:
Code:
require '/absolute/path/to/chronic'
Obviously this needs to be done with care or you are going to run into difficulties if you move the script to another system.
If this is part of a Rails application I find this works well:
Put your maintenance scripts in the root of your application and then add this to the start of the script:
Code:
ENV['RAILS_ENV'] = 'production'
require 'config/environment.rb'
That effectively makes all the objects and plug-ins available to your Rails application also available to the script. It also sets the environment to 'production' so maintenance tasks run against the correct data.
Bookmarks