Loading data from yml produces strange result?

I have a yml file of states of the US and Canada. I am loading them
into a State model.
State is defined with a migration
t.column :name, :string
t.column :abbrev :string

In my file states.yml, I have entries of this form
massachusetts:
name: Massachusetts
abbrev: MA

then I have a migration that loads the state information

directory = File.join(File.dirname(FILE), “dev_data”)
Fixtures.create_fixtures(directory, “states”)

Everything works as expected, until I try to load the data for Ontario
the yml entry is
ontario:
name: Ontraio
abbrev: ON

When I run this, the database entry for the Ontario abbreviation
becomes “1”, a string with the character 1

That isn’t what I want. I have managed to work around this by using
the abbreviation ONE, and then taking the first two characters with
slice(0,2) whenever I want an abbreviation.

However, that seems like a band-aid.

ON is perhaps a reserved word, or triggering some behavior I don’t
understand ?

Any help or insight would be appreciated.

I would like Ontario to have the two character abbreviation ON

On Fri, 2008-06-27 at 08:19 -0700, mtz wrote:

understand ?

Any help or insight would be appreciated.

I would like Ontario to have the two character abbreviation ON


try enclosing it in quotes…
abbrev: ‘ON’

Craig

On 27 Jun 2008, at 16:19, mtz wrote:

However, that seems like a band-aid.

ON is perhaps a reserved word, or triggering some behavior I don’t
understand ?

I think yaml recognises certain pairs as being booleans (true/false
etc…). You can defeat that by putting the value in quotes.

Fred

GREAT !

That worked. Thanks.

On Jun 27, 11:29 am, Frederick C. [email protected]