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
Blazer app colliding with my main ApplicationController and app's routes #66
Comments
Blazer is a separate engine, but it uses your |
@aguynamedben I got Blazer working with Authlogic with a tiny workaround. You get to specify one # config/blazer.yml
before_action :activate_authlogic_and_require_admin
# app/controllers/application_controller.rb
private def activate_authlogic_and_require_admin
activate_authlogic
require_admin
end (In this case Works like a charm and doesn't feel too hacky, always the sign of a good workaround. :) @ankane Would you guys accept a PR that updated the README.md with this info? |
Hey @cannikin, thanks for sharing. I'm happy to include instructions for Authlogic if it's non-trivial. However, I don't see any reference to the approach above in the Authlogic docs. Is this specific to your app? https://github.com/binarylogic/authlogic |
@ankane Nope not specific to my app, it'll happen in any controller that tries to access something that Authlogic provides (like Since Blazer clears out all You can see it appending the And then what that action actually does here: https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/controller_adapters/rails_adapter.rb#L58 Any controller that inherits from ApplicationController (including Blazer) would get that It would definitely be cleaner to just call before_action: activate_authlogic, require_admin Or maybe: before_action: activate_authlogic
before_action: require_admin I'll actually update my code sample above to use the built-in |
When removing callbacks, we could keep |
Ooo, that would be even cleaner for Authlogic folks! I can work on that if you'd like. PR in the next few days? |
👍 works for me |
Just created #140 |
Hi, I'm trying to install blazer to try it out. I'm running into a few weird issues where Blazer is colliding with my main app.
My core question is: Is Blazer supposed to be mounted as an entire separate app, similar to Sidekiq's web interface? Or is Blazer supposed to inherit code (controller, routes) from my main app?
Environment:
I followed the README very directly...
rails g blazer:install
mount Blazer::Engine, at: "blazer"
in config/routes.rbThe first problem I run into is this error when loading /blazer:
My main app uses the authlogic gem. The traceback for this error leads to a method in app/controllers/application_controller.rb (my main application controller).
Blazer::BaseController
subclassesApplicationController
, and it's using my main app'sApplicationController
. Is this intentional?When I comment out the offending authentication function in
ApplicationController
, the /blazer path loads, but all URL generation on the page fails and none of the links work (i.e. can't a new dashboard). The log says:rake routes
shows:Somehow, it seems like Blazer is again, when looking for routes, looking in the routes for my app, not the Blazer Engine routes. From reading about Rails Engines, it seems like the intention is for none of Blazer's code to use my ApplicationController or routes, but that's not happening.
It's too bad, I wish I could get this working to test. I'm happy to do some extra work around here if you guide me on where to look. Thanks for the time you spend working on this gem, it looks awesome, I hope I can get it working somehow.
The text was updated successfully, but these errors were encountered: