Though I have been working from past 6 years with Ruby on Rails in one of the recent bootstrap session to a small and enthusiastic groups I had noticed one another fine point in the way we use yml files.
Any newbie who is aware of Rails can pretty much recollect that we configure databases, test data and many other information required for application through YAML files.
Like in many of the previous sessions & trainings conducted I had moved on by creating simple rails application. Since it was a bootstrap session and the attendees were doing on their personal laptops couple of them had difficulty in configuring the database. I had zeroed down to database.yml after I got confirmed that they are all running on the right versions of mysql. This was the yml that they have in their applications
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password: 000000
socket: /tmp/mysql.sock
|
As I found it normal I gave another try by myself and landed into same issue so did dig into the logs over there...
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env** Execute db:load_config** Execute db:create
rake aborted!
can't convert Fixnum into String
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.4/lib/mysql2/client.rb:36:in `connect'
So here it is evident that there was a data type mis-match and keeping fingers crossed looked over again at the database.yml and this time zeroed down to the mistake
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password: 000000
socket: /tmp/mysql.sock
|
The password was
000000
an integer type as per the yaml and password was expected as string. Once it was identified the fix was pretty simple
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password: "000000"
socket: /tmp/mysql.sock
|
As always... every bootstrap session will keep on helping me to pick some tricky and interesting points otherwise which could not be easily noticed or observed in our day to day projects.