I wish someone would enlighten me. I cannot for the life of me figure out why we use YML in Ruby. This is not a YML vs XML vs JSON discussion either. It’s a question of why we would use any external configuration file.
External configuration files, as far as I can tell, began because of compiled languages. Back in the day you would compile entire systems down into a jar file, exe, dll or some such file. There would always be those little bits of information though that you could not possibly know. What is the exact path to a particular folder for images? What is the database server address?
Here we are in Rails (or at least those of us that have come over) years later doing the same thing. The funny thing is though, we are doing it half way.
We are in a dynamic, not compiled language. We are using one of the most expressive languages out there. We are don’t have a reason (as far as I can tell) to need a standalone configuration file in another language.
I’ve heard the argument that they are easy to find. If you structure your application correctly, no matter if it’s code or configuration settings, finding them should be obvious (config folders, etc.).
I’m picking on the project a little here, but what got to me was when I saw an example of Mongoid and I saw this:
production: <<: *defaults host: <%= ENV['MONGOID_HOST'] %> port: <%= ENV['MONGOID_PORT'] %> database: <%= ENV['MONGOID_DATABASE'] %>
So now we are mixing ERB with YML? I’m sorry, but this in what I call a code smell. Why are we not just using Ruby?