Now that ActiveRecord::Relation#all is deprecated in Rails 4, how are you supposed to iterate all records?
Used to be like:
Foo.all.each do |foo|
# w
This appears to be an incorrect deprecation warning somewhere in Rails. As of Rails 4.0.2 the warning message still exists. I get the following error when I try and run Foo.all:
DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g.
Post.where(published: true).load
). If you want to get an array of records from a relation, you can call #to_a (e.g.Post.where(published: true).to_a
).
I'm almost 100% certain I watched in a RailsCasts that #all was being changed to return an Relation in Rails 4 (instead of an array) - no mention of deprecation.