更新时间:2023-12-02 09:20:16
使用您的初始代码:
您可以使用 + 连接两个数组,然后获得前 10 个结果:
You can join two arrays using + then get first 10 results:
def self.current
(Article.listed_articles + Article.rescue_articles)[0..9]
end
我想一种非常肮脏的做法是:
I suppose a really dirty way of doing it would be:
def self.current
oldest_accepted = Article.published.order('created_at DESC').limit(25).last
Artcile.published.where(['created_at > ?', oldest_accepted.created_at]).order('listed DESC').limit(10)
end