---
title: "以前に設定した order を上書きしたい場合"
description: "以前に設定した order を（default\\_scope 経由のものでも）上書きしたい場合は、代わりに reorder() を使いましょう。"
canonical: https://oozou.com/til/if-you-want-to-override-previously-set-order-25
locale: ja
date: 2020-10-13
topic: ruby-on-rails
---

# 以前に設定した order を上書きしたい場合

> 以前に設定した order を（default\_scope 経由のものでも）上書きしたい場合は、代わりに reorder() を使いましょう。

Published: 2020-10-13 · Topic: [ruby on rails](https://oozou.com/ja/til-topics/ruby-on-rails) ([markdown](https://oozou.com/ja/til-topics/ruby-on-rails.md))

以前に設定した order を（default\_scope 経由のものでも）上書きしたい場合は、代わりに reorder() を使いましょう。

例：

```ruby
User.order('id ASC').reorder('name DESC')
```

とすると、id による並び替えは完全に無視されます

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/ja/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
