【发布时间】:2008-11-18 00:08:03
【问题描述】:
如果我有...
class Bunny < ActiveRecord::Base
has_many :carrots
end
...如果@bunny 有胡萝卜,我如何查看视图?我想做这样的事情:
<% if @bunny.carrots? %>
<strong>Yay! Carrots!</strong>
<% for carrot in @bunny.carrots %>
You got a <%=h carrot.color %> carrot!<br />
<% end %>
<% end %>
我知道@bunny.carrots? 不起作用——怎么办?
【问题讨论】:
标签: ruby-on-rails ruby model