Skip to content

Instantly share code, notes, and snippets.

@nyaahara
Created December 11, 2014 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyaahara/2d2e4111fbe87b5d587b to your computer and use it in GitHub Desktop.
Save nyaahara/2d2e4111fbe87b5d587b to your computer and use it in GitHub Desktop.
scopeでwhereしてorder(nullを含める)
# hogeがnullのレコードが下になってソートされます。
scope :sorted_hoge_with_null, -> { where(status: :none).order('hoge IS NULL, hoge ASC') }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment