モデルの 1 つにこの named_scope があります。
named_scope :latest_100,
:from => '(select * from videos order by videos.created_at desc limit 0, 100) as videos'
その目的は、最後の 100 のビデオのプールを作成することです (その結果を「ビデオ」として返すため、他のスコープはそのデータセットで動作します)。その後、スコープをチェーンし、その結果のプールからレコードをフィルター処理できます。
# video.rb
named_scope :most_popular, :order => 'popularity'
named_scope :take_5, :limit => 5
# video_controller.rb
# it gets the latest 100 videos, then sorts those by popularity, and takes the top 5.
@videos = Video.latest_100.most_popular.take_5
Arel に相当するステートメントはありますか?