0

I have a record which I deleted and now I need to reinsert it with the same id as before. I have the whole object saved. Is there a way I can directly insert this back in the db using the console?

Note: I'm on Rails 4

So I understood how to add it, there is one issue I was using devise and now I don't have the whole encrypted password hash. Is there a way around that? Because it is a user account

anonn023432
  • 2,940
  • 6
  • 31
  • 63
  • A lot of suggestions in below link https://stackoverflow.com/questions/431617/overriding-id-on-create-in-activerecord – Shiko Feb 15 '18 at 21:48

1 Answers1

1

Provided you know the password, you could do:

User.new(password: 'user_password').encrypted_password

and insert that value in the db.

Evekay
  • 86
  • 4