I have a need for a scheduler to run from inside of my rails
application. I am familiar with Java (J2EE) and new to Ruby. In Java I
would have used a framework called Quartz. I would have created a
servlet and in the init method started up the Quartz framework. I have
created a new Ruby class and called it StartCron.rb in the Components
folder of my Rails app. I have been playing with the development.rb
file to test my class. I have done this:
[code]
config.after_initialize do
cron = StartCron.new
cron.run
end
[/code]
I get this error when I start WEBrick...
[code]
=> Booting WEBrick...
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in
`const_missing'': uninitialized constant Rails::Initializer::StartCron
(NameError)
from
script/../config/../config/environments/development.rb:24:in
`load_environment''
from
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:335:in
`after_initialize''
from
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:114:in
`process''
from
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer.rb:43:in
`run''
[/code]
Any help would be appreciated.
Here is the StartCron.rb file
[code]
require "rubygems"
require ''openwfe/util/scheduler''
class StartCron
def StartCron.run
OpenWFE.scheduler = Scheduler.new
OpenWFE.scheduler.start
# Simple usage
OpenWFE.scheduler.schedule_every(''2s'') { p
''every 2 seconds'' }
OpenWFE.scheduler.join
end
end
[/code]
This runs fine standalone.
Lee
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---