问题
I'am developing a plugin in redmine how send mail every days , so i install rufus-scheduler and in my Gemfile i add this line
gem "rufus-scheduler "
and also i install the gem
sudo gem install rufus-scheduler --source http://gemcutter.org
and in my redmine/plugins/latest-issues-redmine-plugin/lib/latest_issues/view_hook_listener.rb i do this
class LatestIssuesViewHookListener < Redmine::Hook::ViewListener
require File.join(File.dirname(__FILE__), '../../app/models/latest_issues_setup')
require 'net/smtp'
require 'rubygems'
require 'rufus-scheduler
def load_issues
scheduler = Rufus::Scheduler.start_new
scheduler.every '1h' do
send_email "test@test.com", :body => html
end
end
end
Any ideas for this error ?
Thanks
回答1:
sudo gem install rufus-scheduler --source http://gemcutter.org
installs rubygems via the "gem" command, which, usually, points to the "system" Ruby which is, usually again, not JRuby.
You could probably do
jruby -S gem install rufus-scheduler
to install the gem in the JRuby load path.
回答2:
you write in your Gemfile
gem "rufus-scheduler "
shouldn't it be
gem "rufus-scheduler"
instead?
After adding the line, you'd have to run
bundle install
to let Bundler grab the rufus-scheduler gem (and update the Gemfile.lock file).
IIRC, upon starting the Rails application, Bundler should already have complained about not having rufus-scheduler around. That should have happened before the LoadError. So, are you starting the Rails app with Bundler? (How do you start it anyway?)
回答3:
Try with
require 'rubygems' # tell ruby that you're using rubygems
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new # rufus-scheduler 3.0 style
scheduler.in '5s' do
puts "order ristretto"
end
scheduler.every '10s' do
puts "I feel like drinking coffee"
end
#scheduler.join
You seem to follow an old tutorial. The current readme for rufus-scheduler is at https://github.com/jmettraux/rufus-scheduler
来源:https://stackoverflow.com/questions/22096449/no-such-file-to-load-rufus-scheduler