ActiveRecord Errors are all nil

I have an Active Record model in Rails 2.1 that is doing some
validation, specifically, these methods:

validates_presence_of :name, :email, :phone
validates_uniqueness_of :name
validates_format_of :email, :with => /[email protected]+…{2,4}/
validates_confirmation_of :password
validate :has_password
attr_accessor :password

When I try to save a user object that does not meet all of these
requirements, the object does not save, but there are no errors
either.

Loading development environment (Rails 2.1.0)

user = User.new
=> #<User id: nil, name: nil, email: nil, hashed_password: nil, salt:
nil, phone: nil, created_at: nil, updated_at: nil>

user.save
=> false

user.errors[:name]
=> nil

Any idea what’s going on?

On Aug 10, 10:55 am, Omar Q. [email protected] wrote:

When I try to save a user object that does not meet all of these
requirements, the object does not save, but there are no errors
either.

Using your code (minus the parts regarding the password validation),
in a test rails app works fine here.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs