Skip to content

Commit

Permalink
Update db config access to be more Rails-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
wadewinningham committed Jun 5, 2024
1 parent ddbd0da commit 66afcfe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/data_taster/lib/data_taster/flavors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def recent_ids(table_name, col_name)
end

def source_db
@source_db ||= db_config["database"]
@source_db ||= db_config[:database]
end
end
end
6 changes: 1 addition & 5 deletions packages/data_taster/lib/data_taster/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ def sanitize_command(command, params = nil)
sanitized_command
end

def db_yml
@db_yml ||= YAML.safe_load(ERB.new(Rails.root.join("config", "database.yml").read).result, aliases: true)
end

def db_config
@db_config ||= db_yml[Rails.env].key?("primary") ? db_yml[Rails.env]["primary"] : db_yml[Rails.env]
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").configuration_hash
end

def logg(message)
Expand Down

0 comments on commit 66afcfe

Please sign in to comment.