Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 Initializer Not Loading

I am trying to put my emailer password in a .yml file.

Under config/initializers I have a file emailers_config.rb

require 'yaml'
EMAIL_CONFIG = YAML.load(File.read(Rails.root + "config/mailer_config.yml"))

and in my config/mailer_config.yml I have:

#production password
smtp_password_pro: foo
#devevopment env password
smtp_password_dev: bar

Now it seems My initializes is not running, because I get this uninitialized constant EMAIL_CONFIG (NameError)

Now Rails is supposed to laod everything under the initializers folder, so loading the file is not an issue.

What is wrong here?

like image 422
Trt Trt Avatar asked Dec 01 '13 12:12

Trt Trt


1 Answers

If you are having trouble accessing a constant in your YAML file, try shutting down your local server with control + c, then run:

$ spring stop

Boot up your server or console again:

$ rails [server | console]

And you might have access to that constant.

like image 114
sealocal Avatar answered Oct 11 '22 12:10

sealocal