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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, 2008-06-27 at 08:19 -0700, mtz wrote:> 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---- try enclosing it in quotes... abbrev: ''ON'' Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-27 15:29 UTC
Re: loading data from yml produces strange result ?
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> Any help or insight would be appreciated. > > I would like Ontario to have the two character abbreviation ON > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
GREAT ! That worked. Thanks. On Jun 27, 11:29 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > Any help or insight would be appreciated. > > > I would like Ontario to have the two character abbreviation ON--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---