I am having trouble getting WYMEditor to work correctly in Rails 3.2 production mode with the asset pipeline. Here is my setup:
# app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require wymeditor/jquery.wymeditor.min
//= require_tree .
WYMEditor files are located at vendor/assets/javascripts/wymeditor/*
# in app/views/layouts/application.html.erb just above closing </body> tag
<script type="text/javascript">
$(document).ready(function() {
$('textarea').wymeditor();
});
</script>
In development mode everything works fine. However, after I did rake assets:clean
and rake assets:precompile
and started my server rails s -e production
, the WYMEditor doesn't work anymore. I looked in public/assets/application.js
and it appears the WYMEditor code was included in that file. However, the errors I get seem to indicate that WYMEditor is looking for some of its files relative to the page on which the WYMEditor is included rather than in the public/assets/wymeditor
folder that gets created during the precompilation process:
Started GET "/users/lang/en.js" for 127.0.0.1 at 2012-10-09 16:11:12 -0700
ActionController::RoutingError (No route matches [GET] "/users/lang/en.js"):
Started GET "/users/skins/default/skin.js" for 127.0.0.1 at 2012-10-09 16:11:12 -0700
ActionController::RoutingError (No route matches [GET] "/users/skins/default/skin.js"):
Started GET "/users/iframe/default/wymiframe.html" for 127.0.0.1 at 2012-10-09 16:11:12 -0700
ActionController::RoutingError (No route matches [GET] "/users/iframe/default/wymiframe.html"):
[snipped stack traces and more similar error messages]
After much Googling I came across a page that seemed to indicate that WYMEditor is unhappy when its code is included in application.js
and that it needs to be in its own separate folder. However, I don't know if this is actually true or not. What would be the recommended way to get WYMEditor to work in production mode?