Devise认证未定义方法'to_sym'? [英] Devise authentication undefined method 'to_sym'?
问题描述
我试图使用devise为LDAP活动目录设置身份验证系统。 (遵循教程 http://wiki.phys.ethz.ch/readme/devise_with_ldap_for_authentication_in_rails_3
Im trying to set up an authentication system against an LDAP active directory using devise. (following the tutorial http://wiki.phys.ethz.ch/readme/devise_with_ldap_for_authentication_in_rails_3
Ive遵循指令,当我尝试运行应用程序时,收到以下错误:
Ive followed the instruction exactly, and when i try running the app im getting the following error:
undefined method `to_sym' for #<ActiveModel::MassAssignmentSecurity::WhiteList:0x2a4abd50
我甚至不知道哪里 to_sym
是因为它不告诉我!任何人都知道这个的原因或至少如何找到包含此行的文件?
* ** * ** * 更新 > * ** * ** *
And i dont even know where to_sym
is because it doesnt tell me! Anyone know the cause of this or at least how to find the file that contains this line?
*******UPDATE*******
rb模型:
class User < ActiveRecord::Base
# 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(:login, :password, :password_confirmation, :remember_me)
end
推荐答案
看起来在 devise
方法的最后一个参数后面有一个尾逗号:
It looks like there is a trailing comma after the last argument to the devise
method:
devise :ldap_authenticatable, :rememberable, :trackable,
然后,ruby解释器假设 attr_accessible
是该方法的下一个参数。正确的参数类型是一个符号,所以它调用 to_sym
在 attr_accessible
,这是一种方法,没有
The ruby interpreter then assumes that attr_accessible
is the next argument to the method. The proper argument type is a symbol, so it calls to_sym
on attr_accessible
, which is a method and does not have a to_sym
method and raises the error.
删除尾随的逗号,它应该可以工作!
Remove the trailing comma and it should work!
这篇关于Devise认证未定义方法'to_sym'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!