私は任意の初期順序を提示するためにcustom_orderを使用しようとしています。カスタム注文はSQL ORDER BYコードを無視します
# GET /sequences
def index
@sequences_grid = initialize_grid(Sequence,
enable_export_to_csv: false,
per_page: 10,
custom_order: {
'sequences.username' => "CASE WHEN username LIKE '#{current_user.username}' THEN 0 ELSE 1 END, username"
},
name: 'seq_g1')
end
アイデアは、現在のユーザーのレコードをリストの一番上に置くことです。
ユーザーガイドには、「キーはデータベース列の完全修飾名であり、ORDER BY句で使用するSQLの必要なチャンクを評価する」と記載されています。
データベースエディタで実行するとSQLコードが正常に機能しますが、グリッドに必要な順序が表示されません。
ログは、任意のwice_grid問題について沈黙していると報告された要求は、次のとおりです。私はSQLコードが何らかの方法で壊されてもよいが、私は深く掘る前に、私は、誰かがぶつかったかもしれないと思ったことを疑う
10:10:35 web.1 | Sequence Load (0.3ms) SELECT distinct username FROM "sequences" ORDER BY username asc
10:10:35 web.1 | Sequence Load (0.3ms) SELECT distinct classtype FROM "sequences" ORDER BY classtype asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct description FROM "sequences" ORDER BY description asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct sequencenumber FROM "sequences" ORDER BY sequencenumber asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct target FROM "sequences" ORDER BY target asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct indicator FROM "sequences" ORDER BY indicator asc
同様の問題?
よろしく、 トム。