Q:

Rails reading from settings.yml

Hi is it possible to read from an controller the settings yml? Im using rails 4.2.0
I want to store some global information in the settings.yml to display those in the view
at the moment I try this way:
settingsfile = File.read(Rails.root + "./config/settings.yml")
settingsfile = YAML.load(settingsfile)
settingsfile["default"]

works but when I want to go deeper
settingsfile["default"]["info"]

its empty
Yml File
default:
  supported_languages:
    de: Deutsch
    fr: Francais
    en: English
    it: Italiano
    sv: Svenska
    pt: Português
    nl: Nederlands
    es: Español
  production:
  info:
    version: 2.0.0
    datum: 11.05.2015

A:

without using gem..you can use something like ..
your dev/config/email.yml
 development:
  :address: smtp.service.com
  :port: 25
  :user_name: mike@gmail.com
  :password: mikepassword
production:
  :address: smtp.gmail.com
  :port: 587
  :authentication: plain
  :user_name: mike@gmail.com
  :password: mikepassword
  :enable_starttls_auto: true

you can load this yml file simply like....
  email_settings = YAML::load(File.open("#{Rails.root.to_s}/config/email.yml"))
 ActionMailer::Base.smtp_settings = email_settings[Rails.env] unless email_settings[Rails.env].nil?

also you may use - Rails::Application.config_for(:email) as shown in the documentation for Rails 4+ onwards.

A:

You might try:
@settingsvariable = Settings.default.supported_languages.de

This approach worked in my app.

