I am working on a Ruby on Rails application. I recently updated to the last Rails version (4.2.3) and I discovered when I run rake test
it erase my development database. I am using the Figaro gem to declare all my environment variables.
Here is my application.yml file:
#
# == Database
#
db_host : 'localhost'
db_username: 'root'
db_password: 'root'
development:
db_name: 'database-dev' # Not found by Figaro
test:
db_name: 'database-test' # Not found by Figaro
my database.yml file:
default: &default
adapter: mysql2
pool: 5
timeout: 5000
username: <%= Figaro.env.db_username %>
password: <%= Figaro.env.db_password %>
database: <%= Figaro.env.db_name %>
development:
<<: *default
test:
<<: *default
If I put db_name
under the development
key, I get the message no database selected
but if I move it to the upper level it works. However rake test
doesn't use the test
key either to load the database configuration and erase my development datas.
It was working perfectly before, I don't understand what is wrong. Thanks for your help.
My project:
- Rails 4.2.3
- Ruby 2.2.2
- Figaro 1.1.1