f3n1xa
Last Updated: February 25, 2016
·
1.301K
· aderyabin

Drying Rails database configuration file

My database.yml file for development environment using Postgresql.

defaults: &defaults
  adapter: postgresql
  encoding: utf8
  collation: en_US.utf8
  ctype: en_US.utf8
  template: template0

<% %w(development test production).each do |environment| %>
<%= environment %>:
  <<: *defaults
  database: <%= "#{Rails.application.class.parent_name.downcase}_#{environment}" %>
<% end %>

2 Responses
Add your response

6439

extremely ruby!

over 1 year ago ·
6885

That's far too crazy, it's not readable! And setting a database name by evaluating some ruby code might be ok for development but a bit scary for production :)

Nevertheless, configuration files must be readable!

over 1 year ago ·