---
title: "Rails 开发小贴士积累"
author: "tiroc"
date: "2012-08-24T14:25:55Z"
tags: []
categories: ["编程语言"]
slug: "rails"
draft: false
lastmod: "2012-08-30T18:48:16Z"
id: 1661645
url: "https://tiroc.iteye.com/blog/1661645"
---

Model (ActiveRecord) 中 Boolean 类型的属性，在做是否存在的校验的时候，不能使用 presence: true ,而是要使用 inclusion: { in:  }。否则，当值为 false 的时候，会校验失败。
  ClienSideValidations 对 Boolean 类型的属性做 inclusion 验证的时候，存在一个 bug。如上一条，input 的值是字符串类型的 "true" 和 "false" ，在与 true 和 false 做 == 比较时，inclusion 校验始终为 false;