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

Describe ApplicationController hook in README #1082

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,24 @@ GoodJob includes a Dashboard as a mountable `Rails::Engine`.
end
```

To support custom authentication, you can extend GoodJob's `ApplicationController` using the following hook:

```ruby
# config/initializers/good_job.rb

ActiveSupport.on_load(:good_job_application_controller) do
# context here is GoodJob::ApplicationController

before_action do
raise ActionController::RoutingError.new('Not Found') unless current_user&.admin?
end

def current_user
# load current user
end
end
```

_To view finished jobs (succeeded and discarded) on the Dashboard, GoodJob must be configured to preserve job records. Preservation is enabled by default._

**Troubleshooting the Dashboard:** Some applications are unable to autoload the Goodjob Engine. To work around this, explicitly require the Engine at the top of your `config/application.rb` file, immediately after Rails is required and before Bundler requires the Rails' groups.
Expand Down