 <p>Add this to your <code>ApplicationController</code>:</p> <pre><code>def search @search ||= Search.new end def galleries @galleries ||= Gallery.all end </code></pre> <p>You then use the function (<code>search</code>) in your views instead if the instance variable <code>@search</code>); the <code>||=</code> makes sure the code is executed only once (thus saving database queries).</p>