This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule DeepMerge do | |
defp _merge(key, v1, v2) when is_map(v1) do | |
Map.merge(v1, v2, &_merge/3) | |
end | |
defp _merge(key, v1, v2), do: v2 | |
def merge(map1, map2) when is_map(map1) and is_map(map2) do | |
Map.merge map1, map2, &_merge/3 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
json = ActiveSupport::JSON.decode(File.read('db/seeds/countries.json')) | |
json.each do |a| | |
Country.create!(a['country'], without_protection: true) | |
end |