Closed dplaza closed 1 month ago
I can not reproduce that with a new repo: https://github.com/bogdan/js-routes-test
There need to be some specifics to your problem. Can you reproduce it in public repo?
Also you may do this:
task "assets:precompile" => "routes:inspect"
namescpase :routes do
task inspect: :environment do
puts Rails.application.routes.named_routes.map do |route|
route.name if route.name&.match?(/admin_companies/)
end.compact.inspect
end
end
And see if routes are defined correctly. If they are, it is hard to imagine why JsRoutes doesn't catch them. Becuase it expects them to be in the same place:
https://github.com/railsware/js-routes/blob/master/lib/js_routes/instance.rb#L124
Maybe you have some bug with exclude/include
options for your production env.
Thanks for the quick response, @bogdan! I tried your suggestion, and indeed, the missing routes were not there either.
Good news tho! after some investigation, I was able to pinpoint the issue. The company model in our project has an encrypted field that uses the ignore_case: true
option. This option triggers a database check to verify the existence of a specific column. Since we use this model in ActiveAdmin, when Rails tried to build the routes for it, an error was being caught and silently handled, allowing the rest of the routes to load but excluding all the admin_companies
URLs.
We solved the issue by using nulldb
during precompilation, and now everything is working smoothly! 🎉
Thanks again for looking at this so quickly, really appreciate it!
I just upgraded to the latest version (2.2.10) and I followed the steps to implement the new middleware, and the rake task during deployment, as well as adding
routes.js
androutes.d.ts
to.gitignore
.However, I'm encountering an issue: the routes generated in development and production environments are inconsistent, specifically the ActiveAdmin routes. Here's a simplified example:
Interestingly, this only affects certain ActiveAdmin routes. The routes used by React components (which use JS routes) on AA are fine, but the ones on classic ActiveAdmin views are missing.
By the way, running
rails routes
in both development and production environments returns consistent results.I suspect the production rake task is filtering out routes that aren't used by JS. Is there a way to prevent this?
Additional context
Thanks!