Я мог бы использовать некоторую помощь для понимания запросов Rails в циклах.
Цикл 1:
ruby-1.9.2-p290 :005 > (1..3).each do |i|
ruby-1.9.2-p290 :006 > Unit.find(i)
ruby-1.9.2-p290 :007?> end
Unit Load (0.2ms) SELECT `units`.* FROM `units` WHERE `units`.`id` = 1 LIMIT 1
Unit Load (0.1ms) SELECT `units`.* FROM `units` WHERE `units`.`id` = 2 LIMIT 1
Unit Load (0.1ms) SELECT `units`.* FROM `units` WHERE `units`.`id` = 3 LIMIT 1
=> 1..3
Цикл 2:
ruby-1.9.2-p290 :008 > (1..3).each do |i|
ruby-1.9.2-p290 :009 > Unit.where("id = ?", i)
ruby-1.9.2-p290 :010?> end
=> 1..3
Цикл 3:
ruby-1.9.2-p290 :011 > (1..3).each do |i|
ruby-1.9.2-p290 :012 > Unit.find(i)
ruby-1.9.2-p290 :013?> end
Unit Load (0.2ms) SELECT `units`.* FROM `units` WHERE `units`.`id` = 1 LIMIT 1
Unit Load (0.1ms) SELECT `units`.* FROM `units` WHERE `units`.`id` = 2 LIMIT 1
Unit Load (0.1ms) SELECT `units`.* FROM `units` WHERE `units`.`id` = 3 LIMIT 1
=> 1..3
Почему не работает второй цикл?