Error: Cannot Call Create Unless The Parent Is Saved In Rails

Posted By Weston Ganger

I was having a weird issue in an app where it was spitting an error at me when trying to delete a record: Cannot call create unless the parent is saved

In my case this issue was caused by audited-activerecord and paranoia gems. I found an issue for this and the paranoia author has said this will not be fixed.

So the answer here is just switch the gem acts_as_paranoid instead of paranoia. This should require no code changes.

Also note that I wouldnt recommend using audited-activerecord anymore it has some shortcomings. You should use paper_trail instead because it provides so much more flexibility to you auditing solution and is infinitely better.

Related External Links:

Article Topic:Software Development - Ruby / Rails

Date:March 11, 2016