gpt4 book ai didi

ruby-on-rails - Rails for Zombies - 实验 3 › 练习 4

转载 作者:行者123 更新时间:2023-12-04 06:08:05 25 4
gpt4 key购买 nike

我尝试解决这个练习 2 个小时,但我找不到解决方案?

任何人,请帮忙?

http://railsforzombies.org/labs/3/exercises/16

练习:

Objective

In the each block, if a Zombie has more than 1 tweet, print out SMART ZOMBIE

Your Database:


Zombies
id name graveyard
1 Ash Glen Haven Memorial Cemetary
2 Bob Chapel Hill Cemetary
3 Jim My Fathers Basement

Tweets
id status zombie_id
1 Where can I get a good bite to eat? 1
2 My left arm is missing, but I don't care 2
3 I just ate some delicious brains 3
4 OMG, my fingers turned green. 1

The view code:


<% zombies = Zombie.all %>

<ul>
<% zombies.each do |zombie| %>
<li>
<%= zombie.name %>
# add if statement here
</li>
<% end %>
</ul>

最佳答案

您正在寻找的代码是:

<% if zombie.tweets.count > 1 %>
SMART ZOMBIE
<% end %>

关于ruby-on-rails - Rails for Zombies - 实验 3 › 练习 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5059330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com