We just upgraded our virtual machines to what I thought was an identical ruby configuration (via RVM... Ruby 1.9.2, Rails 3.0.7, DataMapper 1.1.0). The biggest difference was that we went from MySQL 5.0 to 5.1.
For some reason, the exact same code/database.yml that was working on our old VMs now fails on our new ones at the point it tries to connect to the database.
The issue is that this YAML:
mysql_defaults: &mysql_defaults
adapter: mysql
encoding: UTF-8
username: user
password: pass
host: localhost
development:
<<: *mysql_defaults
database: devdb
production:
<<: *mysql_defaults
database: productiondb
host: master.db.site.com
Is just expanding to:
"mysql_defaults" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
},
"development" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
},
"production" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
}
Instead of:
"mysql_defaults" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
},
"development" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost",
"database"=>"devdb"
},
"production" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"master.db.site.com",
"database"=>"productiondb"
}
Anyone experienced this before?
According to Gemfile.lock (I deleted it and ran bundle install again, just for sanity's sake), all the installed dependencies are the same (i.e. the Gemfile.lock does not diff between the old and the new setup). Nor does the database.yml.
The database. yml is a file that is created with new rails applications in /config and defines the database configurations that your application will use in different environments.
The main databases. yml configuration file for a project can be found in the config/ directory. Most of the time, all applications of a project share the same database. That's why the main database configuration file is in the project config/ directory.
Ruby on Rails is an open source web framework written in Ruby. Rails is database agnostic, meaning it can be used with a variety of different databases. By default it assumes that MySQL is being used, but it's quite easy to use with Postgres instead.
Psych is the new YAML parser which is presumably better but can't merge hash keys.
This should help http://pivotallabs.com/users/mkocher/blog/articles/1692-yaml-psych-and-ruby-1-9-2-p180-here-there-be-dragons
Since you have done an upgrade it may be that your database permissions have messed up. Try viewing that you have the necessary permissions i.e the machine on which the code resides has privileges to connect and modify on the database machine. Looking at you database.yml it should be something like"
GRANT ALL PRIVILEGES ON productionbd.* to 'user'@'<app-server-ip>' identified by 'pass';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With