# Not being able to access the info loaded by config.yml

**URL:** <https://www.ruby-forum.com/t/not-being-able-to-access-the-info-loaded-by-config-yml/181062>\
**Category:** Rails\
**Created:** [January 4, 2010, 9:09pm UTC](https://www.ruby-forum.com/t/not-being-able-to-access-the-info-loaded-by-config-yml/181062 "2010-01-04T21:09:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qaswm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/5f8ce5/32.png) [@qaswm](https://www.ruby-forum.com/u/qaswm)\
**Post date:** [January 4, 2010, 9:09pm UTC](https://www.ruby-forum.com/t/not-being-able-to-access-the-info-loaded-by-config-yml/181062/1 "2010-01-04T21:09:59Z")

</div>

Hi,

I have the following app\_config.yml in rails\_root/config/

development: &non\_production\_settings  
:bit\_ly:  
:login: “xxxxxxxxx”  
:api\_key: “xxxxxxxxx”  
:history: “0”

test:  
\<\<: \*non\_production\_settings

production:  
:bit\_ly:APP\_CONFIG = YAML.load(File.read(RAILS\_ROOT +  
“/config/app\_config.yml”))[RAILS\_ENV]  
:login: “xxxxxxxxx”  
:api\_key: “xxxxxxxxx”  
:history: “1”

i am loading this config file with following

APP\_CONFIG = YAML.load(File.read(RAILS\_ROOT +  
“/config/app\_config.yml”))[RAILS\_ENV]

in my lib/somefolder/comeclass i am calling

APP\_CONFIG[:bit\_ly][:history] which results in an error ‘const-missing’

what can be the reason?

---

<div class="post-metadata">

**Author:** ![qaswm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/5f8ce5/32.png) [@qaswm](https://www.ruby-forum.com/u/qaswm)\
**Post date:** [January 4, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/not-being-able-to-access-the-info-loaded-by-config-yml/181062/2 "2010-01-04T21:23:45Z")

</div>

Am 04.01.2010 um 21:09 schrieb Quee WM:

> “/config/app\_config.yml”))[RAILS\_ENV]
> 
> in my lib/somefolder/comeclass i am calling
> 
> APP\_CONFIG[:bit\_ly][:history] which results in an error ‘const-missing’
> 
> what can be the reason?

I think yaml keys need to be strings, not symbols, i.e. that would read:

development:  
bit\_ly:  
login: something  
api\_key: secret  
history: 0

Felix

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![qaswm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/5f8ce5/32.png) [@qaswm](https://www.ruby-forum.com/u/qaswm)\
**Post date:** [January 4, 2010, 9:51pm UTC](https://www.ruby-forum.com/t/not-being-able-to-access-the-info-loaded-by-config-yml/181062/3 "2010-01-04T21:51:47Z")

</div>

> I think yaml keys need to be strings, not symbols, i.e. that would read:
> 
> development:  
> bit\_ly:  
> login: something  
> api\_key: secret  
> history: 0
> 
> Felix

Well I followed the info provided here:

> **[Making Configuration Files with YAML: Revised](https://innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/)**
>
> So back in July 2007 I posted a blog on making configuration files with YAML, and I’ve been noticing a lot of readership on the old article. Because it seems that a lot of people are reading …

and am able to access the data easily

the error i get for this code here:

URI.parse(“[http://api.bit.ly/shorten?version=2.0.1&longUrl=](http://api.bit.ly/shorten?version=2.0.1&longUrl=)” + string  
+“&login=” + APP\_CONFIG[:bit\_ly][:login] + “&apiKey=” +  
APP\_CONFIG[:bit\_ly][:api\_key] + “&history=” +  
APP\_CONFIG[:bit\_ly][:history] + “&format=xml”)

is

NameError: uninitialized constant CreateUrl::APP\_CONFIG  
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active\_support/  
dependencies.rb:105:in `const_missing' from /home/rails/app1/lib/mycode/create_url.rb:6:in `bit\_ly\_for\_vehicle’
