#206 updated_at の並び順修正
This commit is contained in:
@@ -65,15 +65,20 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
sort_sql =
|
||||
if order[0] == 'original_created_at'
|
||||
case order[0]
|
||||
when 'original_created_at'
|
||||
'COALESCE(posts.original_created_before - INTERVAL 1 MINUTE,' +
|
||||
'posts.original_created_from,' +
|
||||
'posts.created_at) ' +
|
||||
order[1]
|
||||
'posts.created_at) '
|
||||
when 'updated_at'
|
||||
'posts.updated_at_all'
|
||||
else
|
||||
"posts.#{ order[0] } #{ order[1] }"
|
||||
"posts.#{ order[0] }"
|
||||
end
|
||||
posts = q.order(Arel.sql("#{ sort_sql }")).limit(limit).offset(offset).to_a
|
||||
posts = q.order(Arel.sql("#{ sort_sql } #{ order[1] }, id #{ order[1] }"))
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.to_a
|
||||
|
||||
q = q.except(:select, :order)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user