varvet / pundit

Minimal authorization through OO design and pure Ruby classes
MIT License
8.29k stars 632 forks source link

Invalid policy scope constructor called #572

Closed ghost closed 5 years ago

ghost commented 5 years ago

I've posted this question on Stackoverflow -- but I've found that the real error is actually:

Relation passed to #or must be structurally compatible. Incompatible values: [:joins]

But this is not the actual exception thrown by pundit, which is very very misleading and led me down a rabbit hole. If you feel nothing needs to be done, please close the issue, but I think the best thing would be to bubble up such an error instead of throwing an invalid constructor error when it is not?

Linuus commented 5 years ago

Can you please give more information? Please show the code you are using.

Also, what version of pundit are you using? This might be fixed already. See #550

I saw that it hasn’t been released though. I’ll try to release a new version after the holidays.

ghost commented 5 years ago

I'm sorry I thought I had added the link, but I didn't - https://stackoverflow.com/questions/53890188/invalid-constructor-error-for-pundit-policy-scopes-when-using-or-logical-union

ghost commented 5 years ago

We're using 2.0.0 so it is likely fixed, then. Feel free to close if you agree.

Linuus commented 5 years ago

I’ll close this when the next release is out.

Linuus commented 5 years ago

2.0.1 has now been released which includes this bugfix: https://rubygems.org/gems/pundit/versions/2.0.1

jesster2k10 commented 5 years ago

Hey, I'm still getting this issue on 2.0.1

My policy file looks like this

/policies/account_policy.rb

class AccountPolicy
  def initalize
  end

  def index?
    true
  end
end

(btw I'm using it bundled with jsonapi-authorization)

Linuus commented 5 years ago

Your constructor is wrong so the error should be thrown.

jesster2k10 commented 5 years ago

Your constructor is wrong so the error should be thrown.

Hey, what should my constructor look like?

My error stack looks like this

"exception": "Invalid #<AccountPolicy> constructor is called",
                "backtrace": [
                    "/Library/Ruby/Gems/2.3.0/gems/pundit-2.0.0/lib/pundit.rb:130:in `rescue in policy!'",
                    "/Library/Ruby/Gems/2.3.0/gems/pundit-2.0.0/lib/pundit.rb:126:in `policy!'",
                    "/Library/Ruby/Gems/2.3.0/gems/pundit-2.0.0/lib/pundit.rb:68:in `authorize'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-authorization-1.0.0/lib/jsonapi/authorization/default_pundit_authorizer.rb:31:in `find'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-authorization-1.0.0/lib/jsonapi/authorization/authorizing_processor.rb:52:in `authorize_find'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:426:in `block in make_lambda'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:605:in `catch'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:605:in `block in default_terminator'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:199:in `block in halting'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:513:in `block in invoke_before'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:513:in `each'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:513:in `invoke_before'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:131:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/processor.rb:57:in `block in process'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/processor.rb:56:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation.rb:16:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:58:in `block in process_operation'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:63:in `with_default_handling'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:57:in `process_operation'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:29:in `block (2 levels) in process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:28:in `each'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:28:in `block in process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:46:in `transaction'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:24:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:86:in `block in process_operations'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:85:in `process_operations'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:77:in `process_request'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:16:in `index'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:194:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/rendering.rb:30:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:42:in `block in process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:132:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:41:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/rescue.rb:22:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `block in instrument'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `instrument'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/instrumentation.rb:32:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/activerecord-5.2.2/lib/active_record/railties/controller_runtime.rb:24:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:134:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal.rb:191:in `dispatch'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal.rb:252:in `dispatch'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:34:in `serve'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:52:in `block in serve'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:35:in `each'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:35:in `serve'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:840:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/etag.rb:25:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/conditional_get.rb:25:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:559:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/callbacks.rb:26:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/executor.rb:14:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/rack/logger.rb:38:in `call_app'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/rack/logger.rb:26:in `block in call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `block in tagged'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:28:in `tagged'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `tagged'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/rack/logger.rb:26:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/request_id.rb:27:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/runtime.rb:22:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/executor.rb:14:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/static.rb:127:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/engine.rb:524:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/configuration.rb:225:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/server.rb:658:in `handle_request'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/server.rb:472:in `process_client'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/server.rb:332:in `block in run'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/thread_pool.rb:133:in `block in spawn_thread'"
                ]
jesster2k10 commented 5 years ago

Your constructor is wrong so the error should be thrown.

Hey, what should my constructor look like?

My error stack looks like this

"exception": "Invalid #<AccountPolicy> constructor is called",
                "backtrace": [
                    "/Library/Ruby/Gems/2.3.0/gems/pundit-2.0.0/lib/pundit.rb:130:in `rescue in policy!'",
                    "/Library/Ruby/Gems/2.3.0/gems/pundit-2.0.0/lib/pundit.rb:126:in `policy!'",
                    "/Library/Ruby/Gems/2.3.0/gems/pundit-2.0.0/lib/pundit.rb:68:in `authorize'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-authorization-1.0.0/lib/jsonapi/authorization/default_pundit_authorizer.rb:31:in `find'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-authorization-1.0.0/lib/jsonapi/authorization/authorizing_processor.rb:52:in `authorize_find'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:426:in `block in make_lambda'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:605:in `catch'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:605:in `block in default_terminator'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:199:in `block in halting'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:513:in `block in invoke_before'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:513:in `each'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:513:in `invoke_before'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:131:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/processor.rb:57:in `block in process'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/processor.rb:56:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation.rb:16:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:58:in `block in process_operation'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:63:in `with_default_handling'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:57:in `process_operation'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:29:in `block (2 levels) in process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:28:in `each'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:28:in `block in process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:46:in `transaction'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/operation_dispatcher.rb:24:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:86:in `block in process_operations'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:85:in `process_operations'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:77:in `process_request'",
                    "/Library/Ruby/Gems/2.3.0/gems/jsonapi-resources-0.9.5/lib/jsonapi/acts_as_resource_controller.rb:16:in `index'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:194:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/rendering.rb:30:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:42:in `block in process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:132:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/callbacks.rb:41:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/rescue.rb:22:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `block in instrument'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `instrument'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/instrumentation.rb:32:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/activerecord-5.2.2/lib/active_record/railties/controller_runtime.rb:24:in `process_action'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/abstract_controller/base.rb:134:in `process'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal.rb:191:in `dispatch'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_controller/metal.rb:252:in `dispatch'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:34:in `serve'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:52:in `block in serve'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:35:in `each'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:35:in `serve'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:840:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/etag.rb:25:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/conditional_get.rb:25:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activerecord-5.2.2/lib/active_record/migration.rb:559:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:98:in `run_callbacks'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/callbacks.rb:26:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/executor.rb:14:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/rack/logger.rb:38:in `call_app'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/rack/logger.rb:26:in `block in call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `block in tagged'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:28:in `tagged'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `tagged'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/rack/logger.rb:26:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/request_id.rb:27:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/runtime.rb:22:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/activesupport-5.2.2/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/executor.rb:14:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/actionpack-5.2.2/lib/action_dispatch/middleware/static.rb:127:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/railties-5.2.2/lib/rails/engine.rb:524:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/configuration.rb:225:in `call'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/server.rb:658:in `handle_request'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/server.rb:472:in `process_client'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/server.rb:332:in `block in run'",
                    "/Library/Ruby/Gems/2.3.0/gems/puma-3.12.0/lib/puma/thread_pool.rb:133:in `block in spawn_thread'"
                ]

I figured out the issue! My bad. I think some clearer documentation on that might help.

Changing

def initialize
end

to

def initialize(user, record)
    @user = user
    @record = record
end
Linuus commented 5 years ago

Sorry, I was on my phone and was a bit short on time. Glad you figured it out :)