I understand how to run a simple piece of code in rails console. say
Swimming::Student.create(:name="Jerry")
How do I run a big piece of code (many lines)
Swimming::Student.all.each{ |student|
student.attended = flase
student.save
}
Just hit enter, as you'd 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With