如何为Rails gem指定rvm gemsets?

MyApp使用的是rvm gemset 1.9.3@rails-3.2。 这不是默认的。

我正在使用gem“随时”定期发送电子邮件通知。 这是我的日程表.rb:

every 1.minutes do runner "MyModel.send_emails" # if ... end 

除非gemset 1.9.3@rails-3.2是默认值,否则Cron作业不起作用。 我如何改进我的schedule.rb,以便为我的scheduller使用另一个gemsets(不仅是默认的@global)。

我已经阅读了官方文档: 无论何时和rvm问题以及有关“rvm gemsets for every”的stackoverflow问题,但都没有找到答案。

我试图在我的shedule.rb中放入以下代码(根据RVM-Notes中的建议):

 job_type :runner, "{ cd #{@current_path} > /home/####/.rvm/gems/ruby-1.9.3-p448@ rails-3.2/bin/rails; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output" 

但它没有结果:

 ERROR: /home/###/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92 :in `block in materialize': Could not find i18n-0.6.5 in any of the sources (Bundler::GemNotFound) 

如何为Rails gem指定rvm gemsets’随时’? 非常感谢!

UPDATE

1)我试图为我的Gemfile提供rvm notaions,如下所示:

 ruby=ruby-1.9.3-p448 # with # sign ruby-gemset=rails-3.2 # with # sign 

它没有结果。 没有什么变化。

2)我试图修改我的〜/ .rvmrc。 使用bundle,rails的完整路径的实验给出了以下错误列表:

  /usr/bin/env: ruby: No such file or directory /usr/bin/env: ruby: No such file or directory /bin/bash: bundle: command not found /bin/bash: bundle: command not found /usr/bin/env: ruby_executable_hooks/usr/bin/env: ruby_executable_hooks: No such file or directory : No such file or directory 

这里通过job_type实验:

 #job_type :runner, "{ cd #{path}; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output" job_type :runner, "{ cd #{path}; } && RAILS_ENV=:environment /home/###/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec rails runner ':task' :output" #job_type :runner, "cd #{path} && RAILS_ENV=development /home/###/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec /home/###/.rvm/gems/ruby-1.9.3-p448@rails-3.2/bin/rails runner ':task' :output" 

使用包装器:

 job_type :runner, "cd #{path} && RAILS_ENV=development /home/###/.rvm/wrappers/ruby-1.9.3-p448@rails-3.2/bundle exec rails runner ':task' :output" 

这将加载适当的rvm环境并在其上下文中运行bundle ,bundler仅添加环境变量以使用Gemfile而不修改加载的ruby环境。

这里描述了类似的情况http://rvm.io/integration/init-d

尝试

 job_type :runner, "cd :path && RAILS_ENV=:environment bundle exec rails runner :task :output" 

假设你在Gemfile提到过

 #ruby=ruby-1.9.3-p448 #ruby-gemset=rails-3.2 

有关此表示法,请参阅RVM文档

尝试在项目根目录中创建.rvmrc文件,并具有以下行

 rvm use 1.9.3@rails-3.2