named_scope が Rails 1.2.6 と 2.0.4 に back port されたらしい

RubyFlowより。
Ruby on Rails の named scope は、O/R マッパーの使い勝手を大きく改善するが、これは Rails 2.1 からの新機能であり、古い Rails では動かない。
しかし、これを古い Rails に移植したツワモノがいるそうだ。

NamedScope For Those Left Behind: This is not simple hack of named scope like you might find in WillPaginate. This is a fully backported and tested version of NamedScope that will work on rails 1.2.6 or 2.0.4. The most important part of this plugin is that it is TESTED. In fact all the test are Shoulda/FactoryGirl ports of the tests currently found in rails 2.1.1.
This plugin includes backported code for the ActiveRecord class methods that work in conjunction with NamedScope such as first, last and all. This plugin also includes ActiveRecord.attribute_condition which allows you to use named scopes as conditions in other finder methods.

残された人々のための NamedScope: これは、WillPaginate で見られるような named scope の簡単なハックではない。こいつは NamedScope の 1.2.6 と 2.0.4 への移植 (バックポート) である。移植したバージョンは、完全でかつテストもされている。このプラグインでいちばん大事なのは、十分にテストされているということである。事実、すべてのテストは Rails 2.1.1 で動かした Shoulda/FactoryGirl からのテストの移植である。
このプラグインは、first や last や all といった、NamedScope を使った結合 (conjunction) で動作する ActiveRecord クラスメソッドの移植を含んでいる。このプラグインはまた、他の検索用メソッドの中で named scope を条件として使うための、 ActiveRecord.attribute_condition も含んでいる。

NamedScope For Those Left Behind - RubyFlow

すげえ。
今さら古い Rails に移植してどれだけうれしいかはわからないけど、すごいことをやってのけたことだけは確かだ。


Named scope について知りたい方は ここ が詳しい。