Closed frenkel closed 2 years ago
Apparently config.assets.digest
is now true
in development mode as well. Due to the fact that the asset helpers are not loaded, this will result in the error. I've worked around it for now by setting config.assets.digest = false
in environments/development.rb
Looks related to this: https://github.com/rails/sprockets-rails/issues/103
and this pull request: https://github.com/rails/sprockets-rails/pull/149
I've implemented a fix in 97b0cec1900787852558832be7803130d6fb62d0. Would you be able to give the master branch a go and let me know if you encounter any issues.
A new release 4.1.6 is well overdue so I will make a new release once I have confirmation that this fixes things.
I can confirm that your fix works, as the error has gone away using master. Thanks for the quick response, right on time before the official 4.2.0 release :)
It seems the fix broke TinyMCE combined with Turbolinks, also in production mode. If I set config.assets.digest = false
again, TinyMCE works without problems locally.
This seems to be working okay for me. Are you able to upload a test app that demonstrates the issue?
You can see the problem here:
https://github.com/frenkel/tinymce-rails-problem-demo
Most of the time, the JavaScript error is TypeError: Theme is not a constructor
Thanks @frenkel. I'll dive deeper into this tomorrow but I can at least now reproduce the issue.
Great, thanks for your effort!
It looks like this isn't actually related to the original issue and fix, and is more of a general turbolinks-related issue. For me, the issue occurred regardless of config.assets.digest
.
The fix which worked for me is to move the JavaScript includes (both application.js
and tinymce_assets
) into the document HEAD. I'm not deeply familiar with turbolinks but this doesn't appear to be avoidable.
I also had to add the following code to application.js
to properly remove the editor instance, allowing it to reload when the page was revisited.
$(document).on('page:receive', function() {
tinymce.remove();
});
Thanks for looking into this. However, moving things to the head is not possible for a lot of other scripts in my application. Also, the page blocks when loading if you put your javascript in the head. Is there no way to make this work in the footer?
Thanks!
It's not ideal, I agree, but it appears to be a turbolinks limitation.
As a rule of thumb when switching to Turbolinks, move all of your javascript tags inside the head and then work backwards, only moving javascript code back to the body if absolutely necessary.
Ok, well, thanks for looking into this.
I receive an Sprockets::Rails::Environment::NoDigestError exception when trying to use this gem in a new Rails 4.2.0.beta4 project. The following two files can not be loaded because of this exception:
The exact error is:
How can I fix this?