Error when *just* adding utf8 encoding to database.yaml



I have Ruby 1.8.4 and have my MyISAM db and tables created via the
migration files to utf8. A check with MySQL Front shows that all the
tables and the db have been correctly created as I wanted them.

I want the site to be in UTF8 format, and added the bit to
application_controller.rb to get the correct header. All still worked
fine at this stage. But I run into trouble when adding:

encoding: utf8

to my otherwise untouched database.yaml.

I had just committed a working version of the site to subversion before
editing database.yaml and after the database.yaml the the next command I
ran, ruby script/generate model job_client_type, came up with an error:

C:/ruby/lib/ruby/1.8/yaml:133:in ‘load’: syntax error on line 13, 10:
‘adapter: mysql’ (ArgumentError)
[Many other errors on initializer.rb, custom_require.rb etc - I can list
all if it helps]
Ends with […]active_support/dependencies.rb:147: in ‘require’ from
script/generate: 3

Tried figuring out the problem for hours but can’t.

Only a termination of Webrick, deletion of the site and re-export from
subversion with the original database.yaml fixes everything again (i.e.
the model command runs). Merely taking out the offending line from
database.yaml to effectively reverse the change does not do the trick
even though it should - fresh export only, which is weird.

Any ideas?


BTW, if it helps, I was following the instructions on


Do you have some stray tabs in the file?

~ Ben


Ben R. wrote:

Do you have some stray tabs in the file?

~ Ben


Sorry about the delay - was in the middle of a model creation/testing
and wanted to finish and commit to subversion before attempting to
recreate the error.

As soon as you mentioned this, I was very positive you had cracked it as
ArachnoRuby is a bit too tab-happy…

I changed the file in Wordpad, and it seems this was fine. Tabs were the
culprit… or rather my stupidity for the oversight. A tab instead of
two spaces kills everything - script/generate, script/server etc.

Would be nice for it not to be so temperamental in a future release, but
thanks a million Ben.