<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>ayaketan</author_name>
  <author_url>https://blog.hatena.ne.jp/ayaketan/</author_url>
  <blog_title>ayaketanのプログラミング勉強日記</blog_title>
  <blog_url>https://ayaketan.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>SQLite3では、点数を降順で並べる下記のようなスコープで、nullが末尾に来ていたが、PostgreSQLだと、nullが先頭に来てしまった。 scope :order_score_desc, -&gt; { order(score: :desc) } そこで、下記のように、(列名 is null)を追加してあげると、PostgreSQLでもnullが末尾に来た。 scope :order_score_desc, -&gt; { order(&quot;(score is null)&quot;, score: :desc) } もちろん、SQLite3でも正常に動作した。 参考： WEB開発備忘録 PostgreSQL…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fayaketan.hatenablog.com%2Fentry%2F2014%2F08%2F06%2F113000&quot; title=&quot;Rails4 PostgreSQLで数値を降順にソートしたらnullが先頭になってしまった - ayaketanのプログラミング勉強日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-08-06 11:30:00</published>
  <title>Rails4 PostgreSQLで数値を降順にソートしたらnullが先頭になってしまった</title>
  <type>rich</type>
  <url>https://ayaketan.hatenablog.com/entry/2014/08/06/113000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
