我理解如何在rails控制台中运行一段简单的代码。说
Swimming::Student.create(:name="Jerry")
如何运行大量代码(多行)
Swimming::Student.all.each{ |student|
student.attended = flase
student.save
}
答案 0 :(得分:23)
按照你的预期点击输入:
$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