# Newbie question: Value from YML file into a class

**URL:** <https://www.ruby-forum.com/t/newbie-question-value-from-yml-file-into-a-class/139071>\
**Category:** Ruby\
**Created:** [May 30, 2008, 4:17pm UTC](https://www.ruby-forum.com/t/newbie-question-value-from-yml-file-into-a-class/139071 "2008-05-30T16:17:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darryl\_LSPierce](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a87d85/32.png) [@Darryl\_LSPierce](https://www.ruby-forum.com/u/Darryl_LSPierce)\
**Post date:** [May 30, 2008, 4:17pm UTC](https://www.ruby-forum.com/t/newbie-question-value-from-yml-file-into-a-class/139071/1 "2008-05-30T16:17:26Z")

</div>

On my project we’re using ActiveLdap. One of our classes, called  
Account. It  
extends the ActiveLdap::Base class and has a call to define it’s LDAP  
mappings as follows:

class Account \< ActiveLdap::Base  
ldap\_mapping :dn\_attribute =\> ‘cn’, prefix =\> ‘cn=users,cn=accounts’  
end

The value passed to prefix, though, needs to come from a YML file. But,  
I’m  
not sure how to get the value there. I’ve tried loading the YML  
elsewhere  
and accessing the value, but I’m perpetually getting a nil value. In  
another class, named LdapConnection, I load the YML and, from Account,  
try  
to grab the “prefix” value, but no luck.

Any help/advice is appreciated.

---

<div class="post-metadata">

**Author:** ![Darryl\_LSPierce](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a87d85/32.png) [@Darryl\_LSPierce](https://www.ruby-forum.com/u/Darryl_LSPierce)\
**Post date:** [May 30, 2008, 7:09pm UTC](https://www.ruby-forum.com/t/newbie-question-value-from-yml-file-into-a-class/139071/2 "2008-05-30T19:09:38Z")

</div>

On May 29, 2008, at 6:09 PM, Darryl L. Pierce wrote:

> But, I’m  
> not sure how to get the value there. I’ve tried loading the YML  
> elsewhere  
> and accessing the value, but I’m perpetually getting a nil value. In  
> another class, named LdapConnection, I load the YML and, from  
> Account, try  
> to grab the “prefix” value, but no luck.
> 
> Any help/advice is appreciated.

probably the yaml keys are strings and you are accessing them via  
symbols.

a @ [http://codeforpeople.com/](http://codeforpeople.com/)
