I have this resource:
require 'active_resource'
class User < ActiveResource::Base
self.site = 'http://localhost:3000/api/v2'
self.include_format_in_path = false
schema do
attribute :id, :integer
attribute :name, :string
attribute :password, :string
attribute :email, :string
end
validates :email, confirmation: true
# alternatively, tried with:
# validates_confirmation_of :email
end
When I call:
user = User.new(
name: 'My name',
email: 'an@email.com',
email_confirmation: 'another@email.com',
password: 'some_password'
)
and then user.errors
, I would expect it to return an error about the email_confirmation
not matching email
. However, it doesn't. user.valid?
always returns true
.
Moreover, user.email
returns 'an@email.com'
, but user.email_confirmation
returns nil
.
I tested validating the password too, and looks like any user.xxx_confirmation
will return nil
.
How are we supposed to validate confirmations on ActiveResource?