ActiveRecord::Migration.say_with_time() 做
ActiveRecord::Migration.say_with_time() do
当我们应该在种子 file.in rails 框架活动记录中使用它时。
ActiveRecord::Migration.say_with_time() do
此方法获取一个块并对其进行基准测试。打印出花费的时间和受影响的行数。
例如,来自文档:
say_with_time "Reverting all service rates to nil." do
Service.update_all( :rate, nil )
end
# Output
-- Reverting all service rates to nil.
-> 0.3451s
-> 2233 rows
当我们应该在种子 file.in rails 框架活动记录中使用它时。
ActiveRecord::Migration.say_with_time() do
此方法获取一个块并对其进行基准测试。打印出花费的时间和受影响的行数。
例如,来自文档:
say_with_time "Reverting all service rates to nil." do
Service.update_all( :rate, nil )
end
# Output
-- Reverting all service rates to nil.
-> 0.3451s
-> 2233 rows