# Use Symbols from yaml file

**URL:** <https://www.ruby-forum.com/t/use-symbols-from-yaml-file/126303>\
**Category:** Rails\
**Created:** [January 17, 2008, 7:17am UTC](https://www.ruby-forum.com/t/use-symbols-from-yaml-file/126303 "2008-01-17T07:17:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![George\_Bray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@George\_Bray](https://www.ruby-forum.com/u/George_Bray)\
**Post date:** [January 17, 2008, 7:17am UTC](https://www.ruby-forum.com/t/use-symbols-from-yaml-file/126303/1 "2008-01-17T07:17:24Z")

</div>

I’m loading application-wide variables from a yaml file, and one of  
them is a symbol

development:  
LDAP\_HOST: ‘ldap.x.edu.au’  
LDAP\_PORT: ‘636’  
LDAP\_ENC: ‘:simple\_tls’  
…

That works fine, and I use the vars like this:

```
ldap_con = Net::LDAP.new(
  :host => APP_CONFIG['LDAP_HOST'],
  :port => APP_CONFIG['LDAP_PORT'],
  :encryption => {:method => eval(APP_CONFIG['LDAP_ENC'].to_s)}
  )

```

Converting the third variable LDAP\_ENC to a string, then evaluating it  
looks ugly. Is there a better way to draw on symbols from a yaml  
file?

Or how about a syntax to dynamically specify the name of the symbol if  
what’s stored in the yaml file is just

LDAP\_ENC: ‘simple\_tls’

## thanks!

George Bray, The Australian National University, Canberra, Australia.

---

<div class="post-metadata">

**Author:** ![George\_Bray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@George\_Bray](https://www.ruby-forum.com/u/George_Bray)\
**Post date:** [January 17, 2008, 7:37am UTC](https://www.ruby-forum.com/t/use-symbols-from-yaml-file/126303/2 "2008-01-17T07:37:18Z")

</div>

> Converting the third variable LDAP\_ENC to a string, then evaluating it  
> looks ugly. Is there a better way to draw on symbols from a yaml  
> file?

You can put the unquoted symbol right into the yaml file:

LDAP\_ENC: :simple\_tls

Aaron
