Search code examples
ruby-on-railsrubymodelsrails-models

How to solve: validates.rb:96:in `rescue in block in validates': Unknown validator (...)


I'm start learning Rails, and I can't go forward because I'm getting a error when I try to run:

bundle exec rspec spec/

I think the error is on my "models/users.rb" file:

class User < ActiveRecord::Base
  attr_accessible :email, :name

  before_save { |user| user.email = email.downcase }

  validates :name, presence: true, length: { maximum: 50}
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, format: {with: VALID_EMAIL_REGEX }, 
                                uniquiness: {  case_sensitive: false }
end

Before this, I do a wrong thing: where I should type

      uniquiness: { case_sensitive: false }

I typed:

      uniquiness { case_sensitive: false }

And, before I saw this error, I made some changes in my project (created a migration, run the local server, etc.). I remember that I performed these commands:

      bundle exec rake db:migrate
      bundle exec rake db:test:prepare
      bundle exec rspec /spec

Following is the error I got:

Rack::File headers parameter replaces cache_control after Rack 1.5. /usr/lib/ruby/gems/1.9.1/gems/activemodel-3.2.12/lib/active_model/validations/validates.rb:96:in `rescue in block in validates': Unknown validator: 'UniquinessValidator' (ArgumentError) (...)

Someone can help me? Thanks for everyone :P


Solution

  • It's spelled uniqueness not uniquiness.