2009年5月3日 星期日

Rails 2.3 Extras

Rails 2.3 Extras

Batch Find
What's New in Edge Rails: Batched Find

One quick caveat exists: you can’t specify :order or :limit in the options to find_each or find_in_batches as those values are used in the internal looping logic.

Batched finds are best used when you have a potentially large dataset and need to iterate through all rows. If done using a normal find the full result-set will be loaded into memory and could cause problems. With batched finds you can be sure that only 1000 * (each result-object size) will be loaded into memory



Dynamic Scopes
What's New in Edge Rails: Dynamic Scope Methods



Default Scopes
What's New in Edge Rails: Default Scoping



Object#try
try()

you can avoid nil-checking by writing code like <%= @person.try(:name) %>. Well, now it’s baked right into Rails. As implemented in Rails, it raises NoMethodError on private methods and always returns nil if the object is nil.



Smart Rendering of Partials
What's New in Edge Rails: render Stops Being High-Maintenance



Unified Rendering

沒有留言: