Broken links
I installed the gem as suggested but the urls created by the url helper inside the Blazer engine are broken.
For example when going to /blazer, the "New Query" button points to
http://localhost:3000/blazer/assets?action=new&controller=blazer%2Fqueries
I can manually go to /blazer/queries/new, the page renders well, but once again the form endpoint is broken so I'm not able to create a query.
When running rails routes I do see all the engine routes (and in particular /queries/new)
Routes for Blazer::Engine:
....
new_query GET /queries/new(.:format) blazer/queries#new
....
Please let me know if I can help in any way or provide more info.
Hey @sds-dubois, thanks for reporting 👍 Are you able to reproduce with a fresh app?
Cleaning up stale issues
The same issue was described in #198 and I'm experiencing it as well. I created a fresh application and it worked. I also installed devise, introduced the devise auth constraint from the readme and wrapped the Blazer mount line in namespace :admin do and it all worked. I've so far been unable to reproduce in a fresh app but I'll keep working on it. @sds-dubois did you ever narrow this issue down?
Update: The more I dig the more confusing this gets. I forked Blazer and inserted a pry. It looks like the _nav partial isn't being used but that's beside the point. In a fresh app:
> checks_path
=> "/admin/blazer/checks"
[2] pry(#<#<Class:0x00007fa4f35117e8>>)> self.method(:checks_path).source_location
=> ["/Users/joshuaflark/.rvm/gems/ruby-2.7.0-preview1/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb", 320]
In my app:
checks_path
=> "/admin/blazer/assets?action=index&controller=blazer%2Fchecks"
self.method(:checks_path).source_location
=> ["/usr/local/bundle/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb", 320]
I've seen some related issues on other engines in issues that are very old. It has to be a config issue.
i'm also facing the same issue. i cannot find where the assets in the url come from.
@ankane I can confirm, seeing the same issue on Rails 6, ruby 2.7.1, blazer 2.3.1. Tracked the issue down to this suggested fix: https://stackoverflow.com/questions/42490350/rails-engine-routes-do-not-work-without-adding-the-engine-prefix#comment72127863_42490350
I can confirm that removing include Rails.application.routes.url_helpers from ApplicationHelper fixes the issue completely.
module ApplicationHelper
# include Rails.application.routes.url_helpers
...
cc Other reporters of this issue: @firdausmaarof @archonic @sds-dubois @badogar @Pazzik
@BrianSigafoos Thanks. It worked. how can we fix the blazer to prevent the problem? pg_hero works fine without having to change anything in my application
The problem was in Blazer::BaseController < ApplicationController When i replaced it with Blazer::BaseController < ActionController::Base everything fixed. @ankane can we add this as a fix to the blazer?
For those who have encountered a similar problem. My final solution This is to add these lines
module Blazer
class ApplicationController < ActionController::Base
end
end
to config/initializers/blazer.rb
cc Other reporters of this issue: @firdausmaarof @archonic @sds-dubois @badogar @BrianSigafoos
Hey @BrianSigafoos and @Pazzik, thanks for sharing. Blazer inherits from ApplicationController so it can use authentication from it (since not all frameworks hook into ActionController::Base).
Out of curiosity, what's the use case for including URL helpers in ApplicationHelper? (haven't seen that pattern before)
@ankane I agree URL helpers in Application Helper aren't needed. Removing from an old codebase fixed the issue for me.
If lots of other folks need them, blazer could prefix its routes in templates with blazer.
Ex: new_query_path -> blazer.new_query_path. I believe that would also fix the issue.
@BrianSigafoos Can you give master a shot? From my testing, clear_helpers should fix it.
@ankane Confirmed that master now fixes the issue, with include Rails.application.routes.url_helpers in ApplicationHelper. 🎉 🙏