我想使用fresh_when last_modified: @conversations.maximum(:updated_at)
進行分頁。但是,當@conversations
位於第2頁時,即使該集合中有一條記錄,updated_at
仍會返回爲nil
。選擇偏移量> 0的最大值返回零
irb(mail):001:0> conversations = conversations.paginate(page: 1)
=> [10 conversations]
irb(main):002:0> conversations.maximum(:updated_at)
(3.0ms) SELECT MAX(`inbox_conversations`.`updated_at`) AS max_id FROM `inbox_conversations` LIMIT 10 OFFSET 0
=> 2013-01-09 05:12:10 UTC# Correct
irb(main):003:0> conversations = conversations.paginate(page: 2)
=> [10 conversations]
irb(main):004:0> conversations.maximum(:updated_at)
(2.7ms) SELECT MAX(`inbox_conversations`.`updated_at`) AS max_id FROM `inbox_conversations` LIMIT 10 OFFSET 10
=> nil # Not correct
左連接需要我tnk –
左連接和內連接沒有區別。 – maletor
您正在從11-20中提取結果在那個位置有任何數據 –