title: whenever => cron job not accessing my model/database
body: <p>I am using whenever gem to create a cron job. This cron job needs to run a helper method on my rails app at a regular interval. This helper method checks every instance of my model and decides to update it or not.</p>
  
  <p>/app/helpers/auctions_helper.rb:</p>
  
  <pre><code>module AuctionsHelper
  
    def self.checkForExpiredAuction
      # method to update each auction that has expired
      puts "There are currently #{Auction.count} auctions."
  
      @auctions = Auction.all
      @auctions.each do |auction|
        if auction.end_time &gt; Time.now.utc
          auction.price = 1000000
          auction.save
          puts "just updated #{auction.product} auction"
        end
      end
      puts "just updated any auctions that had expired"
    end
  end
  </code></pre>
  
  <p>schedule.rb:</p>
  
  <pre><code>set :output, "log/cron_log.log"
  every 1.minute do
    runner "AuctionsHelper.checkForExpiredAuction"
  end
  </code></pre>
  
  <p>which creates the following cronjob:</p>
  
  <pre><code># Begin Whenever generated tasks for: bestBay
              * * * * * /bin/bash -l -c 'cd /home/bestbay &amp;&amp; script/rails runner -e production '\''AuctionsHelper.checkForExpiredAuction'\'' &gt;&gt; log/cron_log.log 2&gt;&amp;1'
  #    End Whenever generated tasks for: bestBay
  </code></pre>
  
  <p>The problem I'm having is that the helper method can't access the table 'auctions'. From my cron_log.log:</p>
  
  <pre><code>Could not find table 'auctions' (ActiveRecord::StatementInvalid)
  </code></pre>
  
  <p>This doesn't seem to be a problem with the helper method itself. If I run from terminal:</p>
  
  <pre><code>rails runner AuctionsHelper.checkForExpiredAuction
  </code></pre>
  
  <p>I get a nice set of outputs from my puts messages. So why can't my cronjob access my model/table?</p>