gpt4 book ai didi

ruby-on-rails - rails console - 运行一段代码

转载 作者:数据小太阳 更新时间:2023-10-29 06:45:28 26 4
gpt4 key购买 nike

我了解如何在 Rails 控制台中运行一段简单的代码。说

 Swimming::Student.create(:name="Jerry")

我如何运行一大段代码(很多行)

 Swimming::Student.all.each{ |student|
student.attended = flase
student.save
}

最佳答案

如您所料,只需按回车键:

$rails c
Loading development environment (Rails 3.2.13)
2.0.0p0 :001 > Student.all.each do |student| #enter
2.0.0p0 :002 > puts student #enter
2.0.0p0 :003?> end #enter
# here comes the output

关于ruby-on-rails - rails console - 运行一段代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16875668/

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