我正在使用最新的 Devise gem 运行 rails 3.2.5。我有一个与 Actor 类相关的用户类。如果我使用以下语法,则有一个名为 slug 的字段可以很好地验证...
validates :slug, :presence => true, :length => { :maximum => 50 }
但是如果我放置额外的唯一性参数
validates :slug, :presence => true, :length => { :maximum => 50 }, :uniqueness => true
它抛出一个错误......
NoMethodError in Devise::RegistrationsController#update
undefined method `text?' for nil:NilClass
我不确定是什么原因造成的。
我还应该提到,在我的用户模型类中,我有以下内容......
attr_accessible :name, :email, :password, :password_confirmation, :language, :remember_me, :profile_attributes, :admin, :slug
在我的配置文件中,我有
config.active_record.whitelist_attributes = false #not standard nor recommended I know