almo
almo

Reputation: 6367

Chartkick + Rails 7 (Turbo) + Heroku

I have a Rails 7 app using Turbo. I wam using Chartkick (+ Chart.js) and put some charts on my page.

On my local setup it works all fine but after deploying to Heroku I get a strange problem.

When I access the page with the charts by entering the URL in the URL bar, the charts get loaded correctly. But when I navigate to the page with the charts using some link, the charts only show "Loading...". When I disable turbo on my links (<a href="" data-turbo="false"...>) the charts also work. So there is some issue with turbo.

I can run Chartkick in the JS console which gives me an object containing all charts on the page. In the cases where the charts are not working this does not return any charts so I can't even do chart.redraw().

Again, this is only on Heroku. On my local development setup everything works perfectly.

I googled a lot but without results. Any idea where to start investigating this?

Upvotes: 0

Views: 299

Answers (1)

Luigi
Luigi

Reputation: 1

I also had problems with heroku after several tests this configuration worked

/config/importmap.rb
pin "chartkick", to: "chartkick.js"
pin "Chart.bundle", to: "Chart.bundle.js"

/app/assets/javascript/application.js
//= require Chart.bundle 
//= require chartkick

/app/javascript/application.js
import "chartkick"
import "Chart.bundle"

Upvotes: 0

Related Questions