LRBlog

Logical Reality Design: Web Design and Software Development

Archive for June, 2009

Rails fixture strings that are all numbers

June 22, 2009

I ran into this one today: If you need to specify a string in a YAML file (fixtures or the like) but that string is all digits, put it in quotes.

The problem YAML file looked like this:

spec/fixtures/people.yml (broken)


one:
funky_database_id: 0000012345

two:
funky_database_id: 0000012346

The trouble with this is that yaml interprets those values as integers, not strings, and Person#funky_database_id is a string column. So Ruby conveniently loads the value as an integer and runs to_s on it before inserting. Worse, because these start with 0, they get translated from octal. So people(:one).funky_database_id comes out "5349". Definitely not what I wanted.

This works as expected:

spec/fixtures/people.yml (fixed)


one:
funky_database_id: "0000012345"

two:
funky_database_id: "0000012346"

New York Times article about UniThrive

June 13, 2009

One of my clients, UniThrive, was just written up in the New York Times. Go check it out!

An excerpt:

In the photo, the young person’s eyes are brown and kind-looking. She is in need of financial help. A new Web site that brings together the charitable minded and those in need has posted the details of her request.

This is not one of those arrangements where donors can sponsor a needy child or a sorghum farmer in the developing world. The person asking for help is a 21-year-old neurobiology major at Harvard, and she is requesting a loan from Harvard alumni.