I’m adding a validator inside the User.rb model to validate the birthdate given is over 18 years old before create the devise user.
This is the validation I have.
# user.rb
validates :birthdate, :before => lambda { 18.years.ago }, :before_message => "must be at least 18 years old"
Inside the User schema
# User schema
t.date "birthdate"
Problem is that I’m getting the following error when trying to save the object.
ArgumentError in Devise::RegistrationsController#create
Unknown validator: 'BeforeValidator'
Unknown validator: 'BeforeValidator'means you’ve overestimated the magic 🙂Try this: