How to refresh an object at a certain time each day in a rails app?
<p>This might be a bit of a basic question, but I searched and wasn't able to find an answer. </p>

<p>In my rails app, I show a random joke on the page whenever the page loads. What I'd actually like to implement is a 'joke of the day', where the same joke displays all day and then refreshes each day at midnight. Can anyone point me in the right direction?</p>

<p>Here's the code I'm currently using to display a random joke:</p>

<pre><code> class JokesController &lt; ApplicationController
    def index
        @joke = Joke.limit(5).order("RANDOM()").last
    end
 end
</code></pre>

<p>And my view:</p>

<pre><code>&lt;div class="col-sm-10 saying"&gt;
      &lt;%= @joke.saying.html_safe %&gt; 
&lt;/div&gt;
</code></pre>

<p>Thanks in advance!</p>