rubysherpas / paranoia

acts_as_paranoid for Rails 5, 6 and 7
Other
2.89k stars 529 forks source link

Rails 5.1.2 ApplicationRecord problem #411

Open noctivityinc opened 7 years ago

noctivityinc commented 7 years ago

Has anyone gotten this gem to work with API only mode in Rails 5?

Running via Spring preloader in process 61611
Loading development environment (Rails 5.1.2)
2.4.1 :001 > p = Plan.first
NameError: undefined local variable or method `acts_as_paranoid' for Plan (call 'Plan.connection' to establish a connection):Class
atog commented 7 years ago

require 'paranoia' in your ApplicationRecord. That should do it.

danielrhodes commented 7 years ago

Having the same issue. The above did not work.

atog commented 7 years ago

@danielrhodes strange, that was the only thing I did to get it working on my side. Ruby version 2.4.1.

bublik commented 6 years ago

you can stop your Spring, and next again start app and is will work.

cabe56 commented 5 years ago

Still happening (same message as OP), no clue how I fixed it. Turned off the server, restarted the console and problem disappeared.

jarednorman commented 5 years ago

It's highly unlikely that this is a bug with paranoia itself. Paranoia uses ActiveSupport to monkeypatch ActiveRecord::Base once ActiveRecord is loaded. If that happened, the method will be defined.

Either paranoia wasn't required or ActiveSupport's on_load feature isn't working as expected (or maybe something more specific to your apps.)