Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method unique' on calling Rails.application.eager_load!` in rails initializer of other gem #3

Closed
sharshenov opened this issue Jul 23, 2020 · 0 comments · Fixed by #4
Assignees
Labels
bug Something isn't working

Comments

@sharshenov
Copy link
Member

sharshenov commented Jul 23, 2020

Calling of Rails.application.eager_load! in an Rails initializer (/config/initializers/foobar.rb) raises error

NoMethodError: undefined method `unique' for MyJob:Class

The Railtie initializer of ActiveJob::Uniqueness runs later. Therefore the ActiveJob::Uniqueness::Patch is not applied yet.

There is no benefits to have 'active_job_uniqueness.patch_active_job' Railitie initializer. Switching to plain AS callback would resolve the problem

@sharshenov sharshenov changed the title Calling Rails.application.eager_load! in initializer undefined method unique' on calling Rails.application.eager_load!` in rails initializer of other gem Jul 23, 2020
@sharshenov sharshenov self-assigned this Jul 23, 2020
@sharshenov sharshenov added the bug Something isn't working label Jul 23, 2020
sharshenov added a commit that referenced this issue Jul 23, 2020
The Railtie initializer makes the patch to be applied much later than ActiveJob is loaded.
It could lead to a NoMethodError if something unusual happens during Rails application load (like calling `Rails.application.eager_load!` in an initializer)

```
NoMethodError: undefined method `unique' for MyJob:Class
```

fixes #3
sharshenov added a commit that referenced this issue Jul 23, 2020
The Railtie initializer makes the patch to be applied much later than ActiveJob is loaded.
It could lead to a NoMethodError if something unusual happens during Rails application load (like calling `Rails.application.eager_load!` in an initializer)

```
NoMethodError: undefined method `unique' for MyJob:Class
```

fixes #3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant