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 %>
Written by Andrey Deryabin
Related protips
2 Responses
extremely ruby!
over 1 year ago
·
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#