如何在ActiveRecord对象上调用范围数组?

我有一个Article模型,它具有recentcompiledfeatured范围。 我可以像这样链接这些范围:

 Article.recent.compiled.featured 

现在我有一系列这些范围:

 scopes = [:recent, :compiled, :featured] or scopes = [:recent, :compiled] 

我事先不知道scopes变量中有多少个范围。 我只知道它是一系列范围。

如何在上面提到的Article模型上调用此数组作为范围链?

只需使用注入:

 scopes.inject(Article){ |ar,scope| ar.send(scope) }