2011-11-01 60 views

回答

3

您的簡化代碼適用於最新的穩定版本,但無論如何,如果您在使用default_scope + unscoped時遇到奇怪的行爲,它必定是由此AR bug引起的。 https://rails.lighthouseapp.com/projects/8994/tickets/5386-arbaseunscoped-inconsistency

因此,作爲文檔sais,我建議您避免在方法鏈接中使用unscoped方法。改爲使用塊樣式。 https://github.com/rails/rails/blob/2407a7a/activerecord/lib/active_record/base.rb#L938

Article.unscoped { Article.page(nil).per(30) }.to_sql