# Found a silly bug in YAML Fixtures

**URL:** <https://www.ruby-forum.com/t/found-a-silly-bug-in-yaml-fixtures/138638>\
**Category:** Rails\
**Created:** [May 26, 2008, 9:07am UTC](https://www.ruby-forum.com/t/found-a-silly-bug-in-yaml-fixtures/138638 "2008-05-26T09:07:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikrant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cc9497/32.png) [@vikrant](https://www.ruby-forum.com/u/vikrant)\
**Post date:** [May 26, 2008, 9:07am UTC](https://www.ruby-forum.com/t/found-a-silly-bug-in-yaml-fixtures/138638/1 "2008-05-26T09:07:41Z")

</div>

Hi,

In fixtures, whenever I define a string as “yes”, it is stored as “t”  
in the database.

Here is an example in YAML.

active\_user:  
username: active\_user  
is\_active: yes

Now when I run the test, and check the test database (SQLite), I find  
string “t” stored in place of “yes” for the column “is\_active”.

Now consider following example (changed “yes” to “yup”) -

active\_user:  
username: active\_user  
is\_active: yup

Now everything goes as expected and string “yup” is stored in database  
for column “is\_active”.

In my code, I use `User.is_active == "yes"`, to check that an user is  
active. And any other value for is\_active means user is inactive.

It took me almost four hours to identify why my tests are failing!

Later found that string “true” is also stored as “t” in database. and  
“no” is stored as “f”.

I’m using -  
Rails 2.0.2  
SQLite 3.5.7  
Ruby 1.8.6 (patch 111)  
Microsoft Winodws XP Home Edtn. SP2

---

<div class="post-metadata">

**Author:** ![vikrant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cc9497/32.png) [@vikrant](https://www.ruby-forum.com/u/vikrant)\
**Post date:** [May 26, 2008, 9:13am UTC](https://www.ruby-forum.com/t/found-a-silly-bug-in-yaml-fixtures/138638/2 "2008-05-26T09:13:35Z")

</div>

Oops just discovered that this is the problem in YAML and not in  
rails.  
Anyway this should be considered as a bug and not a feature.  
reference -  
[http://wiki.rubyonrails.org/rails/pages/ActiveRecordYamlFixtures](http://wiki.rubyonrails.org/rails/pages/ActiveRecordYamlFixtures)

---

<div class="post-metadata">

**Author:** ![vikrant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cc9497/32.png) [@vikrant](https://www.ruby-forum.com/u/vikrant)\
**Post date:** [May 26, 2008, 12:02pm UTC](https://www.ruby-forum.com/t/found-a-silly-bug-in-yaml-fixtures/138638/3 "2008-05-26T12:02:12Z")

</div>

On 26 May 2008, at 08:13, Vikrant wrote:

> Oops just discovered that this is the problem in YAML and not in  
> rails.  
> Anyway this should be considered as a bug and not a feature.  
> reference - [http://wiki.rubyonrails.org/rails/pages/ActiveRecordYamlFixtures](http://wiki.rubyonrails.org/rails/pages/ActiveRecordYamlFixtures)

This is intentional. Instead of checking foo.is\_active == ‘blah’, use  
foo.is\_active?  
If you do want to stop yaml guessing that you’re trying to store a  
boolean, quote it (ie “yes”)  
Fred
