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

Allow customisation of the dashboard controller parent class #687

Closed
ollym opened this issue Aug 3, 2022 · 2 comments
Closed

Allow customisation of the dashboard controller parent class #687

ollym opened this issue Aug 3, 2022 · 2 comments

Comments

@ollym
Copy link

ollym commented Aug 3, 2022

Like you have:

GoodJob.active_record_parent_class = "ApplicationRecord"

Would be good to have similar for the dashboard:

GoodJob.dashboard_controller_parent_class = "ApplicationController"

Where we can control things like authentication more easily, for example we have a Admin::ApplicationController which we have all the authentication already setup as hooks.

Let me know.

@bensheldon
Copy link
Owner

@ollym thanks for opening this issue. With experience, I think I regret the creation of GoodJob.active_record_parent_class = "ApplicationRecord":

  • Sorbet hates it
  • It scares me out when I have to think about autoloading, reloading and Rails initialization order.

I don't have plans to remove it, but the pattern I am thinking of more strongly recommending is configuring via an initializer. Which is less pretty, but I think more resilient from the perspective of Ruby and Rails:

# initializers/good_job.rb

ActiveSupport::Reloader.to_prepare do
  # open up the class and put your behavior in it directly:
  class GoodJob::BaseRecord # <-- probably rename this GoodJob::ApplicationRecord for consistency
    # put behavior here
  end

  class GoodJob::ApplicationController
    # put behavior here
  end
end

But I haven't made a decision. I am not sure.

@bensheldon
Copy link
Owner

This was documented in #1082

@github-project-automation github-project-automation bot moved this from Prioritized Backlog to Done in GoodJob Backlog v2 Nov 27, 2023
@github-project-automation github-project-automation bot moved this to Done in Backlog Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants