Forum: Ruby on Rails ActiveLdap belongs_to and has_many associations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Alexander E. (Guest)
on 2009-01-22 18:41
I am trying to use ActiveLdap for authentication in my rails app. But I
am running into a problem with the "belongs_to" and "has_many"

Here ist how my models look like.

class Person < ActiveLdap::Base
  ldap_mapping :dn_attribute => "uid",
               :prefix => "ou=People",
               :classes => ['top', 'account', 'posixAccount']
  belongs_to :groups, :class => 'Group', :many => 'memberUid'

class Group < ActiveLdap::Base
  ldap_mapping :dn_attribute => "cn",
                            :prefix => "ou=Group",
                            :classes => ['posixGroup','top']
  has_many :member, :class => "Person", :wrap => "memberUid"

According to ActiveLdap documentation I am testing the association.

irb> me = User.find('aebel')
irb> me.groups.each { |group| p };nil
=> nil

So far everything works fine. But when I try to do a membership test, it

irb> me.groups.member? 'wheel'
=> false

My environment:
Rails 2.2.2
AciveLdap SVN revision 802

Any help will be appreciated
Alexander Ebel
This topic is locked and can not be replied to.