In database.yml you define all the settings. How can I access those settings from ruby? I've looked in App::Application::config
, but can't find it there. Also, I remember people were able to configure database settings without yaml, does anyone know how?
Rails defaults to using a SQLite database when creating a new project, but you can always change it later.
ActiveRecord::Base indicates that the ActiveRecord class or module has a static inner class called Base that you're extending.
By default, Rails uses SQLite3. The database files are stored in the /db directory in the root of your app. There should be a file called development.
Rails.configuration.database_configuration
This will give you a hash table with the configurations for each of your environments. E.g. to get your development database name:
Rails.configuration.database_configuration["development"]["database"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With