-
Notifications
You must be signed in to change notification settings - Fork 355
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
hook include of helper to loading of ActionView #275
Conversation
this prevents errors with load order of helpers when using rspec for tests
Looks good. Do you think this warrants a mention in the changelog? |
I think not, because this helper is only used within ActionView, right? So without ActionView being loaded, there's no use in having these helpers available. |
We could consider moving it to an initializer in the railtie/engine: module BootstrapForm
module Rails
class Engine < ::Rails::Engine
initializer "bootstrap_form.action_view" do
ActiveSupport.on_load(:action_view) do
include BootstrapForm::Helper
end
end
end
end
end And maybe also require the helper file in there. |
I am not entirely familiar with the load order problem you are addressing with this, so please go with whatever you think works best. From a code style standpoint, I prefer the |
I will try to setup a sample app which demonstrates the issue. |
I've setup a sample app with some instructions in the README: https://github.com/koenpunt/bootstrap-forms-test |
Thanks for the sample app. I see exactly the problem you've described. Would you like me to merge this as-is, or did you want to switch to the |
Not sure, but I had a similar issue with the SimpleForm gem, so I'll check if that's the case. If so then I will put it up on the Rails mailing list to see if can get some insight in why this happens and what the recommended way of fixing is |
Turns out it is a problem being introduced by |
I've got an answer from @rafaelfranca on the matter:
|
Great, thanks for getting to the bottom of this. Could you add a mention to the bugfixes section of the changelog? Then I'll merge this in! |
Done! |
Thanks! 🙇 |
this prevents errors with load order of helpers when using rspec for tests.
I also think this should be the way to go for loading extensions.
This is small part of the changes from my previous PR #269