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

Introduce base_controller_class config option #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ron-shinall
Copy link
Contributor

Motivation:

It would be nice to use a specific controller from my application as the Solid Errors base controller, the same way that Mission Control Jobs does. For example, if MyAdminController handles all of my authentication, it would be nice to simply tell Solid Errors to inherit from that controller.

Details:

This PR adds a new base_controller_class config option to accomplish this.

Please let me know if this is something you'd be willing to add, and if there any other aspects you'd like me to include or change.

And thank you for Solid Errors! Today I upgraded our production app to use Solid Errors ✌🏼

Copy link
Owner

@fractaledmind fractaledmind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, thank you! I'll do a thorough second review, merge and push a release later this weekend. But looks good on first review.

@ron-shinall
Copy link
Contributor Author

Excellent! In particular I wasn't sure if you'd prefer a method for reading this value, so let me know if you'd want that change.

@ron-shinall
Copy link
Contributor Author

@fractaledmind are there any changes you'd like me to make on this?

Copy link

@mactunechy mactunechy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few suggestions.

@@ -7,6 +7,7 @@

module SolidErrors
mattr_accessor :connects_to
mattr_accessor :base_controller_class, default: "::ActionController::Base"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency we can remove the default here and have it in a getter method as below:

Suggested change
mattr_accessor :base_controller_class, default: "::ActionController::Base"
mattr_accessor :base_controller_class


def test_default_base_controller
assert_equal ActionController::Base, SolidErrors::ApplicationController.superclass
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we're only testing the default Superclass. we could also have test to assert that the custom configured controller is used as expected.

@@ -21,8 +22,6 @@ def username
@username ||= ENV["SOLIDERRORS_USERNAME"] || @@username
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def base_controller_class
   @base_controller_class ||= @@base_controller_class || ::ActionController::Base
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants