[Ruby-activeldap-discuss] ActiveLdap and ActiveRecord compatibility
Kouhei Sutou
kou at cozmixng.org
Sun May 25 02:12:12 EDT 2008
Hi,
In <200805221053.24361.atapiador at dit.upm.es>
"[Ruby-activeldap-discuss] ActiveLdap and ActiveRecord compatibility" on Thu, 22 May 2008 10:53:24 +0200,
Antonio Tapiador del Dujo <atapiador at dit.upm.es> wrote:
> I'm fetching Users from a LDAP directory. I'll wish to set up relations with
> ActiveRecord models, for example Users Profile:
>
> class User < ActiveLdap::Base
> ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=users', :classes =>
> ['uidObject','inetOrgPerson','top']
> end
>
> class Profile < ActiveRecord::Base
> belongs_to :user
> end
>
> But I get errors related to the user_id foreign key in profiles table
>
> ** Using an Integer user_id:
> TypeError: can't convert Fixnum into String
>
> ** User a String user_id, the id is correctly saved but I get:
> >> profile.user
> ArgumentError: Unknown key(s): conditions, include
There are no idea to integrate ActiveRecord's associations
because they use SQL to associate objects. ActiveLdap can't
process SQL because it's a library for LDAP.
> Is there any way to set relations between ActiveLdap and ActiveRecord models?
Just define a method for now:
class Profile < ActiveRecord::Base
def user
User.find(user_id)
end
end
Thanks,
--
kou
More information about the Ruby-activeldap-discuss
mailing list