<p>If I have...</p>

<pre><code>class Bunny &lt; ActiveRecord::Base
  has_many :carrots
end
</code></pre>

<p>...how can I check in the View if <code>@bunny</code> has any carrots?  I want to do something like this:</p>

<pre><code>&lt;% if @bunny.carrots? %&gt;
  &lt;strong&gt;Yay! Carrots!&lt;/strong&gt;
  &lt;% for carrot in @bunny.carrots %&gt;
    You got a &lt;%=h carrot.color %&gt; carrot!&lt;br /&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
</code></pre>

<p>I know <code>@bunny.carrots?</code> doesn't work -- what would?</p>

either:
```
```
if @bunny.carrots.length>0
```
```
or
```
```
unless @bunny.carrots.nil? || @bunny.carrots.length>0
```
```
or
```
```
if @bunny.carrots.any?
```
```
by the way, you will find more operations on collections if you use irb or script/console with require 'irb/completion'