No.
[4] pry(main)> u = User.create(username: "dunderhead", email: "dunderhead@live.com", password: "password")
=> #<User:0x00007fb0c48b17e0
id: nil,
username: "dunderhead",
created_at: nil,
updated_at: nil,
name: nil,
seen_notification_id: 0,
last_posted_at: nil,
password_hash: nil,
salt: nil,
active: false,
username_lower: nil,
last_seen_at: nil,
admin: false,
last_emailed_at: nil,
trust_level: 0,
approved: false,
approved_by_id: nil,
approved_at: nil,
previous_visit_at: nil,
suspended_at: nil,
suspended_till: nil,
date_of_birth: nil,
views: 0,
flag_level: 0,
ip_address: nil,
moderator: false,
title: nil,
uploaded_avatar_id: nil,
locale: nil,
primary_group_id: nil,
registration_ip_address: nil,
staged: false,
first_seen_at: nil,
silenced_till: nil,
group_locked_trust_level: nil,
manual_locked_trust_level: nil,
secure_identifier: nil,
last_digest_at: nil,
flair_group_id: nil,
last_seen_reviewable_id: nil,
password_algorithm: nil>
I did try saving the user before activating, as the error suggested, but to no avail. I don’t know what the error message means by “parent”.
[5] pry(main)> u.save
=> false
[6] pry(main)> u.activate
ActiveRecord::RecordNotSaved: You cannot call create unless the parent is saved
from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/
associations/collection_association.rb:342:in `_create_record'