spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
814 stars 257 forks source link

setting relative urls is a bit nasty #133

Open toddwf opened 10 years ago

toddwf commented 10 years ago

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.

spohlenz commented 10 years ago

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?