title: Rails how to redirect if record is not found
body: <p>I am trying to redirect if the record is not found.
  The page is not redirect and I get the error record not found.</p>
  
  <p>My controller:</p>
  
  <pre><code>def index
  @link = Link.find(params[:id])
  respond_to do |format|
      if @link.blank?
      format.html { redirect_to(root_url, :notice =&gt; 'Record not found') }
      else
      format.html { render :action =&gt; "index" }
      end
  end
  end
  </code></pre>