---
title: "[gem] acts_as_list"
author: "tiroc"
date: "2013-07-09T15:09:07Z"
tags: []
categories: ["编程语言"]
slug: "gem-acts-as-list"
draft: false
lastmod: "2013-07-09T16:55:48Z"
id: 1901946
url: "https://tiroc.iteye.com/blog/1901946"
---

注意事项：
1. 当在 STI 中，用 type 字段来做 scope 时，如果使用 Symbol，就会报错

```ruby

acts_as_list scope: :type

```

原因在：<https://www.ruby-forum.com/topic/91504>
解决办法：改成数组

```ruby

acts_as_list scope: [:type]

```

注意：不能改成 acts_as_list scope: 'type'，因为 String 类型的参数会被直接拿来做 condition 用