0

I am using gem 'paranoia', '~> 1.0' in my rails 3.2.x app. paranoia version installed is 1.3.3

I am getting that error when I do recursive: true I have tried

user.restore! recursive: true

and

User.find(user.id, recursive: true)

I am getting same error.

RodM
  • 426
  • 1
  • 5
  • 19

2 Answers2

1

It looks like a bug with paranoia gem which is fixed in later version. It raises this error when the association is nil.

You can compare the related code between the versions here

Your version: https://github.com/radar/paranoia/blob/v1.3.3/lib/paranoia.rb#LC89

Latest: https://github.com/radar/paranoia/blob/rails4/lib/paranoia.rb#LC107

Basically they are doing a null check in the latest version.

destroyed_associations.each do |association|
      association_data = send(association.name)

      unless association_data.nil? #this condition is missing in your version

You can either patch it or move to the latest version

usha
  • 28,973
  • 5
  • 72
  • 93
  • why is it in [rails3](https://github.com/radar/paranoia/blob/rails3/lib/paranoia.rb#L105) it has the checking for nil. How can I pull that in v1.3.3? I can't go rails4. – RodM Apr 10 '14 at 11:54
0

@RodM the team has move the patch into their repo but not release yet.

Use their git repo as your gem source instead using RubyGems.

Add in Gemfile gem "paranoia", :github => "radar/paranoia", :branch => "rails3"

johnny
  • 13
  • 3