# New error in ActiveRecord when activating user from rails c

**URL:** <https://meta.discourse.org/t/new-error-in-activerecord-when-activating-user-from-rails-c/301269>\
**Category:** Support\
**Created:** [March 28, 2024, 2:13am UTC](https://meta.discourse.org/t/new-error-in-activerecord-when-activating-user-from-rails-c/301269 "2024-03-28T02:13:49Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [March 28, 2024, 10:32am UTC](https://meta.discourse.org/t/new-error-in-activerecord-when-activating-user-from-rails-c/301269/5 "2024-03-28T10:32:59Z")

</div>

You are failing validation here, that’s why.

e.g. the password is too short.

You can bubble up the exception doing this:

```plaintext
u.save!

```

which gives, e.g.:

```plaintext
ActiveRecord::RecordInvalid: Validation failed: Password is too short (minimum is 10 characters)
from /home/robert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/validations.rb:80:in `raise_validation_error'

```

A quicker way of getting to that would have been to add an exclamation mark after the create:

```plaintext
 u = User.create!(username: "dunderhead", email: "dunderhead@live.com", password: "password")

```

An ID will not be assigned until you give the object fully valid attributes, either on create or on save after fixing them.

Only when you have an instantiated object can you proceed to run methods on it.

---

_[View the full topic](https://meta.discourse.org/t/new-error-in-activerecord-when-activating-user-from-rails-c/301269)._
