Doug Alcorn wrote:>The solution is quite simple. In your YAML file, quote the string >like this: > >record: > field: "true" > >And the value should be the string "true" rather than 1. > > > I just recently fought this with some help from #rubyonrails. It''sThe other - shorter - solution would be to use ''t'' / ''f'' without any quoting for the value in the yaml file. The downside is that it''s obviously not that self-explanatory as the way stated above. Kind regards, Dennis Oelkers
I''m trying to run unit tests using fixtures and a PostgreSQL database. The problem is, if the YAML value for a boolean column contains "true" or "false" for a boolean column, Rails tries to insert a 1 or 0. Do I have to do something to tell ActiveRecord to insert real boolean values into that column? Jim -- Jim Menard, jimm-Xhj3G7Rj6JI@public.gmane.org, http://www.io.com/~jimm/ "HTML belongs in email the way vinyl siding belongs on gerbils. Sure its cute at first, but its just plain WRONG!!!" -- .sig of Carmiac
Jim Menard <jimm-Xhj3G7Rj6JI@public.gmane.org> writes:> I''m trying to run unit tests using fixtures and a PostgreSQL database. > The problem is, if the YAML value for a boolean column contains "true" > or "false" for a boolean column, Rails tries to insert a 1 or 0. > > Do I have to do something to tell ActiveRecord to insert real boolean > values into that column?I just recently fought this with some help from #rubyonrails. It''s not actually Rails that''s doing this. It''s the YAML specification. "Yes", "yes", "true", 1 are all counted as 1. Same with false and friends. http://www.yaml.org/refcard.html The solution is quite simple. In your YAML file, quote the string like this: record: field: "true" And the value should be the string "true" rather than 1. -- doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org
On Apr 9, 2005, at 2:07 PM, Dennis Oelkers wrote:> Doug Alcorn wrote: > >> The solution is quite simple. In your YAML file, quote the string >> like this: >> >> record: >> field: "true" >> >> And the value should be the string "true" rather than 1. >> >> I just recently fought this with some help from #rubyonrails. It''s > > The other - shorter - solution would be to use ''t'' / ''f'' without any > quoting for the value in the > yaml file. The downside is that it''s obviously not that > self-explanatory as the way stated above.Thank you, Doug and Dennis. Both of your suggestions worked. Jim -- Jim Menard, jimm-Xhj3G7Rj6JI@public.gmane.org, http://www.io.com/~jimm/ "Is ''anal-retentive'' hyphenated?" -- Alison Bechdel