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

Overriding the controller #68

Closed
scottbarrow opened this issue Oct 14, 2020 · 5 comments · Fixed by #70
Closed

Overriding the controller #68

scottbarrow opened this issue Oct 14, 2020 · 5 comments · Fixed by #70

Comments

@scottbarrow
Copy link
Contributor

scottbarrow commented Oct 14, 2020

Bug Report

Please help us help you by filling out any applicable information in this template and removing the rest!

Describe the bug

Thank you for implementing the controller override @rickychilcott , @julianrubisch .
Unfortunately, I was not available to test this while it was in PR against my codebase, however I'm doing this now and of course I seem to have an issue

To Reproduce

Steps to reproduce the behavior

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots or reproduction

/Users/scott/Code/Ollie/OllieOrder/config/initializers/futurism.rb:3 :

    1: require 'pry'
    2: binding.pry
 => 3: Futurism.default_controller = OrganizationsController

[7] pry(main)> Futurism.default_controller = OrganizationsController
NameError: Couldn't find PdfHelper, expected it to be defined in helpers/pdf_helper.rb
from /Users/scott/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionpack-6.0.3.4/lib/abstract_controller/helpers.rb:163:in `rescue in block in modules_for_helpers'
Caused by LoadError: Unable to autoload constant PdfHelper, expected /Users/scott/Code/Ollie/OllieOrder/app/helpers/pdf_helper.rb to define it
from /Users/scott/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:550:in `load_missing_constant'
[8] pry(main)>

The pdf_helper seems to be a red herring, but do is there a reason I cannot use the controller constants in the initializer?

Versions

Futurism

  • Gem: [e.g. 0.6.0]
@rickychilcott
Copy link
Contributor

rickychilcott commented Oct 14, 2020 via email

@scottbarrow
Copy link
Contributor Author

scottbarrow commented Oct 14, 2020 via email

@rickychilcott
Copy link
Contributor

rickychilcott commented Oct 14, 2020

Now that I think about it, It might be that the initializer is too early for everything to be properly loaded. https://github.com/thoughtbot/clearance/blob/4473448ab00faed7d57582cc38227c8c3d72e511/lib/clearance/configuration.rb#L140 Is an example of how the clearance gem handles it. We will need to change the config to a string version of the class and it will be lazily converted to the class at runtime. I think this is an issue with zeitworks autoload

I may be able to get a PR in tomorrow morning with a change. I also have a nearly finished PR for the parameter passing issue. I ran out of time while fixing up the test suite today.

@scottbarrow
Copy link
Contributor Author

That would make sense, amazing, thank you for chasing this and the params issue!

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 a pull request may close this issue.

3 participants