Rails database.yml seems to break if a ternary is used

rails

#1

I had a database.yml with an inline template expression that generated fine:

 defaults: &defaults
   adapter: mysql2
   ...
   pool: <%= Figaro.env.mysql_pool_size %>

 development:
   <<: *defaults

 test:
   <<: *defaults

I see this appear in the build “Generate database.yml” :heavy_check_mark:

But then I added a ternary expression:

 defaults: &defaults
   adapter: mysql2
   ...
   pool: <%= Sidekiq.server? ? Figaro.env.sidekiq_mysql_pool_size : Figaro.env.mysql_pool_size %>

Now the circle output just shows a small - I assume default/standard - database.yml, ignoring that in my project:

mkdir -p config
echo ‘test:
adapter: mysql2
database: circle_ruby_test
username: ubuntu
host: localhost
’ > config/database.yml

It’s like there’s an exception being silently swallowed and it falls back to the default. I’m unable to see what exactly is causing the problem (and ideally I’d like the test to fail at this point).


#2

For the record, a workaround was essentially found in Circle docs - make a minimal, circle-specific, database.yml and copy it via a “database” section in circle.yml.

database:
  override:
    - mv config/database.circle.yml config/database.yml
    - bundle exec rake db:create db:structure:load

(I’m using structure.sql but usually you would use db:schema:load)


#3