tinymce-rails icon indicating copy to clipboard operation
tinymce-rails copied to clipboard

setting relative urls is a bit nasty

Open toddwf opened this issue 11 years ago • 1 comments

We have a relative URL that rails uses just fine, but setting it up for tinymce requires a manual init with the base url set using a somewhat cumbersome and poorly documented tinymce feature. (I had to deduce it from here: http://stackoverflow.com/questions/4412589/tinymce-paths-how-to-specify-where-to-load-things-like-editor-plugin-js )

The themes.js was getting 404'd because the path was not using the correct base with the relative part included.

Basically I had to do this:

            <script type="text/javascript">
              tinyMCE.baseURL = '<%="#{request.base_url}/relative/assets/tinymce"%>';
              tinyMCE.init({
                mode: 'textareas',
                theme: 'modern'
              });

where 'relative' is my relative url. This was not an issue before using the asset pipline in older ~3.1 versions of rails. It might be helpful to deal with relative urls automatically. Thanks.

I'm also noting this for anyone else who has this problem.

toddwf avatar Apr 23 '14 16:04 toddwf

Overriding config.tinymce.base should allow you to do this a little cleaner. However this shouldn't be necessary when using relative URLs.

Do you have config.relative_url_root defined in your config/application.rb or config/environments/production.rb?

spohlenz avatar May 25 '14 10:05 spohlenz