Skip to content
This repository

Overloading with nulls #13

Open
davemitchell opened this Issue February 24, 2011 · 2 comments

3 participants

dave mitchell Piotr Kuczynski TonyLa
dave mitchell

I was expecting to be able to "unset" a property in an overriding config file. For example, consider the following:

In config/settings.yml
name: Admin
email: root@foo.com

In config/settings/development.yml
name: Nobody
email: null

However, it looks like instead of unsetting the value, the derived property is untouched.
That is, the above case yields:
Settings.name # => Nobody
Settings.email # => root@foo.com

Rather than what I was expecting:
Settings.name # => Nobody
Settings.email # => nil

Bug, or feature?

TonyLa

The reason this is happening is this gem vendor'ed the deep_merge gem

vendor/deep_merge.rb:72
if source.nil? || (!source.is_a?(FalseClass) && source.respond_to?(:blank?) && source.blank?); return dest; end

As you can see it will just skip over any overrides that are false or blank. IMHO this is incorrect and has been fixed in the original gem located here.

https://github.com/danielsdeleo/deep_merge

I just added this dependency to my Gemfile and rails_config will just use the loaded gem instead of the vendored version.

dave mitchell

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.