bekkou68 の日記

Gogengo! や IT 技術など。

EdgeRailsより:polymorphic関連の where が短く書けるようになる

EdgeRails の記事:What's New in Edge Rails #38 | EdgeRails.info

変更内容のコミット:Post.where(:author_id => Author.first) Post.where(:author => Author.first) PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure) PriceEstimate.where(:estimate_of => treasure)

polymorphic関連において以下の2つのメソッドで発行されるクエリが同じになるそうです。短く書けてよさそう〜。

PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure)
PriceEstimate.where(:estimate_of => treasure)

以下の2つも同様だそうです。

Post.where(:author => author)
Post.where(:author_id => author)