Rails console - run code block

I understand how to run a simple piece of code in the rails console. they say

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

How to run most of the code (many lines)

  Swimming::Student.all.each{ |student| student.attended = flase student.save } 
+7
source share
2 answers

Just hit enter, as you would expect:

 $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 
+16
source

just enter it like this. The entire block is executed after completion.

+1
source

All Articles