spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
816 stars 258 forks source link

Wrong load path in production mode #75

Closed Titinux closed 11 years ago

Titinux commented 12 years ago

Hello,

In development mode dynamic script loading is fine (ex: http://localhost:3000/assets/tinymce/langs/fr.js?body=1)

but in production mode path is weired (ex: http://localhost:3000/fr/admin/pages/2/translations/5//langs/fr.js)

I'm using rails 3.2.8, tinymce-rails 3.5.7.1, tinymce-rails-langs 0.1

Thanks in advance

spohlenz commented 12 years ago

Sorry, I'm not able to reproduce the issue.

Are you setting config.tinymce.base anywhere (if so, try removing it)? Can you upload an example app to GitHub?

donv commented 11 years ago

I started getting the same error today. Is there any known workaround or fix?

spohlenz commented 11 years ago

Hi @donv. I still haven't been able to reproduce the issue. Can you answer my question above regarding config.tinymce.base and upload an example to GitHub if possible?

donv commented 11 years ago

Hi @spohlenz !

Thanks for your response! I was not setting config.tinymce.base anywhere. When I set it in config/application.rb

config.tinymce.base = '/assets/tinymce'

it works! Weird thing is that it used to work, and I cannot find any relevant change that should cause a failure.

spohlenz commented 11 years ago

Thanks @donv. That's useful information.

Are you setting either of config.assets.prefix of config.relative_url_root in your configuration?

donv commented 11 years ago

I am not setting config.assets.prefixor config.relative_url_root anywhere in my config.

One setting that triggers the error is JS debugging:

config.assets.debug = false

Setting this to true always fixes the problem. Setting it to false always triggers the error.

donv commented 11 years ago

Now it does not work even with config.tinymce.base set. I cannot be absolutely sure it worked earlier.

donv commented 11 years ago

So, I am still verifying in different environments, but I think I have found my error. I changed

//= require tinymce/tiny_mce

to

//= require tinymce-jquery

and now it works. Is this likely the root cause of my problems?

spohlenz commented 11 years ago

Were you previously using

//= require tinymce/tiny_mce

or

//= require tinymce

The first one won't include the preinit code which sets the TinyMCE base path.

Another thought is that possibly the Sprockets cache isn't being updated. Can you start with your normal configuration and then clear out tmp/cache/assets and restart your Rails server?

donv commented 11 years ago

I was previously using

//= require tinymce/tiny_mce

I realize now that this was wrong, and I see that the README clearly describes the correct usage. Clearing the cache did have effect (files were recompiled), but ultimately the result was the same.

I am now happy! Thank you very much for the great support!

I think you can close this issue now. The OP never responded, and the symptom was identical with mine.

spohlenz commented 11 years ago

Thanks @donv. Glad we could get to the bottom of this.

KonstantinKo commented 10 years ago

This might still be a problem. In a project I'm working on tinymce just started trying to load it's production assets from a strange path not unlike the one from OP. It was used on a page like https://www.projectname.com/articles/new and tried to load assets from paths like https://www.projectname.com/articles/assets0.projectname.com/tinymce/plugins/code/plugins.js It happened out of the blue. Nobody changed anything that had to do with tinymce and it was running well for many months. The only way to fix it was to set config.tinymce.base = '/assets/tinymce' like @donv described. We never set any tinymce configs before (but we do have a config/tinymce.yml) and never even required tinymce/tinymce in the first place.

It might be that this is a new issue that has something to do with using asset hosts (config.action_controller.asset_host = "assets%d.projectname.com") or it might be something similar to this.

spohlenz commented 10 years ago

@KonstantinKo The latest releases (4.0.28.2 and 4.1.0) should fix support for asset hosts without an explicit protocol.

KonstantinKo commented 10 years ago

Yes, thank you. It works now.