7

I was trying to recover an object from my admin mode and it did not work

 Admin.only_deleted.first.recover
  Admin Load (1.9ms)  SELECT "admins".* FROM "admins" WHERE ("admins"."deleted_at" IS NOT NULL) ORDER BY "admins"."id" ASC LIMIT 1
NoMethodError: undefined method `recover' for #<Admin:0xa57f10c>

Any idea?

emerak
  • 274
  • 2
  • 10
  • Have you tried writing it more like the documentation on github? `Paranoiac.only_deleted.where("name = ?", "not dead yet").first.recover` [docs](https://github.com/ActsAsParanoid/acts_as_paranoid) – SidewaysGravity Oct 08 '14 at 21:42

3 Answers3

11

There is now a restore, rather than recover, but its not correctly recovering the dependent records which is a real pain

Chrissy H
  • 461
  • 4
  • 12
0

I don't really know why developers did it but i can see the recover method has a protected visibility.

So you have to call this method from the model, and you can't call it from the outside

Algo
  • 65
  • 6
  • 1
    Well my answer is a mistake and i can't edit. You should use "restore" instead of "recover" – Algo Mar 30 '15 at 18:21
0

Well, seems like the problem is active record version, they moved something and that's why is not restoring any records, it is fixed in the newest version.

emerak
  • 274
  • 2
  • 10