Rails assets pipeline causing problems
I am trying to get tiny_mce to work with my Rails 3.1 application and its almost works.
I have it installed in vendor/assets/tiny_mce and included in my application.js bootstrap:
application.js
//= require jquery
//= require jquery_ujs
//= require_tree .
/开发者_运维问答/= require tiny_mce
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "mce_editor"
});
Now when I view my page with ?debug_assets=true then it doesn't combine the files with sprockets and everything works as expected. However if I get rid of the ?debug_assets=true then it no longer works.
It seems that TinyMce automatically loads a few additional js files (lang files etc) when needed but this doesn't seem to work with rails 3.1. Any ideas how to fix this?
Thanks for your suggestion, I checked the request logs and the needed files were:
ActionController::RoutingError (No route matches [GET] "/home_pages/4/langs/en.js"):
and
ActionController::RoutingError (No route matches [GET] "/home_pages/4/themes/simple/editor_template.js"):
There dozens of different js files in tiny_mce and I am assuming it loads a different set based on which configs you initialise it with. Should I just manually require these extra js files one at a time to my application.js file until rails stops complaining or is there a more general or best practices solution? Thanks
Install the tinymce-rails
gem - it's worked well for me in the past. Delete the tiny_mce folder from your assets/javascripts folder.
Change your manifest to this:
//= require jquery
//= require jquery_ujs
//= require tinymce
//= require_tree .
and it's better to move this to main.js
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "mce_editor"
});
精彩评论