title: Rails: corret way of validate number of records
body: <p>In my case, <code>user</code> has many <code>categories</code>, and I want to prevent user to delete his last <code>category</code>, this is what I did in <code>Categories#destroy</code>:</p>
  
  <pre><code>  def destroy
      if current_user.categories.count &gt; 1
        @category.destroy
        redirect_to categories_url
      else
        flash[:category_notice] = "Cannot destroy the last category"
        redirect_to categories_url
      end
    end
  </code></pre>
  
  <p>Obviously, this solves the problem. But I want to know if there is a corret way of doing it? Or this is just fine?</p>