Search code examples
ruby-on-railsarraysjsonrubynetldap

Getting value formatted as ["example"]


I'm working with NET-LDAP API using Ruby on Rails:

@ldap.search( :base => @treebase, :filter => @filter ) do |entry|
  entry.cn

When I get the entry.cn value it comes formatted as ["example"] How do I get this value without the characters [" "]?


Solution

  • ["example"] means that you've got an array with one string.

    To get the first element of an array in Rails you can call:

    ["example"].first