title: How to detect Rails environment inside whenever
body: <p>This question will probably only make sense if you know about the <strong><a href="https://github.com/javan/whenever" rel="noreferrer">whenever</a></strong> gem for creating <strong>cron</strong> jobs. </p>
  
  <p>For my app, I want to use <code>whenever</code> in all the environments, including <em>testing</em> and <em>development</em>.<br>
  My <code>schedule.rb</code> looks like this:</p>
  
  <pre><code>set :output, {
      :error    =&gt; "#{path}/log/error.log",
      :standard =&gt; "#{path}/log/cron.log"
  }
  
  set :environment, Rails.env.to_sym
  every 5.minutes do
    rake 'db:activity:synchronize'
  end
  </code></pre>
  
  <p>but it fails on <code>Rails.env.to_sym</code> (<em>and the same stands for</em> <code>RAILS_ENV</code>):</p>
  
  <pre><code>/home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval': uninitialized constant Whenever::JobList::Rails (NameError)
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `initialize'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever.rb:15:in `new'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever.rb:15:in `cron'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/command_line.rb:41:in `run'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/command_line.rb:8:in `execute'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/bin/whenever:38:in `&lt;top (required)&gt;'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/bin/whenever:19:in `load'
      from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/bin/whenever:19:in `&lt;main&gt;'
  </code></pre>
  
  <p>So, my question basically boils down to: </p>
  
  <ol>
  <li>How do I access the current environment, <em>or</em></li>
  <li>What should I do to use <code>whenever</code> in all the environments?</li>
  </ol>