why am i getting undefined method `destroy' for nil:NilClass?
<p>I want to delete something posted by a user. But it's not working the way it normally does despite the fact that I'm mirroring a setup I've used in other apps.</p>

<p>My html:</p>

<pre><code> &lt;div class="section-wrap"&gt;
    &lt;% @colors.each do |color| %&gt;
        &lt;div class="swatch"&gt;
        &lt;div class="colorblock" style="background-color: &lt;%= color.backgroundcolor %&gt;"&gt;
        &lt;/div&gt;
        &lt;h2&gt;PANTONE&lt;sup&gt;2&lt;/sup&gt;&lt;/h2&gt;
        &lt;p&gt;&lt;%= color.name %&gt;&lt;/p&gt;
      &lt;/div&gt;
          &lt;div class="controls"&gt;
            &lt;% if current_user %&gt;
                &lt;%= link_to 'Delete', @color, method: :delete %&gt;
                &lt;% end %&gt;
            &lt;/div&gt;
    &lt;% end %&gt;
&lt;/div&gt;
</code></pre>

<p>My controller action:</p>

<pre><code>def destroy
   @color.destroy
   redirect_to root_path
end
</code></pre>

<p>My routes.rb (in which I should not have to specify the delete route):</p>

<pre><code>resources :colors
delete 'colors', to: 'colors#destroy'
</code></pre>

<p>And then <code>rake routes</code> gives the route I'd expect:</p>

<pre><code>DELETE /colors/:id(.:format)        colors#destroy
</code></pre>

<p>But I get <code>undefined method 'destroy' for nil:NilClass</code></p>