2017-09-28から1日間の記事一覧

Rails RansackでNULLS LASTでsortする

Ransackのconditionには入れられないらしい NULLS LASTでsortするには Ransackの外側で普通にOrder指定する Model.search(conditions).result.order('column DESC NULLS LAST') 脱Ransackしたい 参考 How to add NULL LAST to sorts · Issue #443 · activere…

RailsでPostgreSQLにNULLS LASTのインデックスを追加する方法

タイトルママ nulls lastのインデックスを作りたいけどなかなか見つからなかったので書きました。 migration にこれ add_index :table, :column, order: { column: 'DESC NULLS LAST' } 参考 PostgreSQL: Ordering, NULLs, and indexes - makandropedia 元の…