我正在运行最新的Devise和ldap插件的rails 3.1。我已经交换了使用电子邮件地址的默认行为,现在使用Novell eDir中的uid属性作为我的用户字段。设计/ LDAP - 在db中保存额外的ldap属性
我可以登录,我得到基于根路径等
什么,我现在是让电子邮件和我的LDAP命名类别和插入到数据库中的自定义属性struggeling重定向。我试图让before_save工作。
class User < ActiveRecord::Base
before_save :get_ldap_email
before_save :get_ldap_category
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :ldap_authenticatable, :rememberable, :trackable
# Setup accessible (or protected) attributes for your model
attr_accessible :uid, :category, :email, :password, :password_confirmation, :remember_me
def get_ldap_email
self.email = Devise::LdapAdapter.get_ldap_param(self.uid, "mail")
end
def get_ldap_category
self.category = Devise::LdapAdapter.get_ldap_param(self.uid, "category")
end
end
我可能是愚蠢的,但我不能得到这个工作。我在登录时看到以下输出:
NoMethodError in Devise::SessionsController#create
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Rails.root: /home/ntr/Dropbox/source/devise
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"jljpH9bUXrPeBVy4jKnJoAfeuO/EiF0YxRqxm07VF5w=",
"user"=>{"uid"=>"ntr",
"password"=>"[FILTERED]",
"remember_me"=>"0"},
"commit"=>"Logga in"}
Show session dump
Show env dump
Response
Headers:
None
我在做什么错?很想得到一些帮助!
问候 //罗杰
您是否发现错在哪里? – Ninad
我不得不说不,我害怕。但似乎我并不是唯一遇到这个问题的人。 –