11

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

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

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

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

1 回答 1

28

正如您所料,只需按 Enter 键:

$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
于 2013-06-01T18:10:32.843 回答