spohlenz / tinymce-rails

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

tinymce doesn't work in production #65

Closed heygambo closed 11 years ago

heygambo commented 12 years ago

Hi, I tried to use your gem, which is very easy to setup. Thanky for that!

But somehow I have a problem using it in production. I can't figure it out why. In development mode tinymce gets fully initialized. In production mode it stops somehow.

development mode development mode

production mode production mode

I can't click inside and the tinymce DOM Body element doesn't have as much attributes as the working one. It seems like at a certain point the initalization stops.

Do you have an idea how to solve this?

Regards, Gambi

spohlenz commented 12 years ago

Do you see any errors appearing in your browser's javascript console/error logger?

heygambo commented 12 years ago

No. All assets are loaded properly I think. There are no 404s on javascript oder css files. There are no errors in the console :( So I've no clue where to search for errors, yet.

EDIT: I also change the production server to not compress and unify all assets. This doesn't work either.

I'm on heroku.

heygambo commented 12 years ago

I may change my app so you can have a look at it without logggin in?

spohlenz commented 12 years ago

Sure, can you post (or email me) a URL, or alternatively create a GitHub repo with an app that shows the issue.

brunomac commented 12 years ago

Have the same issue. A lot of assets are not compiled or the url to them is not well formed...

ynes commented 12 years ago

Same Issue, in dev it is working find but in production I have this error "Uncaught ReferenceError: tinyMCE is not defined"

brunomac commented 12 years ago

Solved the problem by precompiling all locally. (rails 3.2 in heroku) added in production.rb config.assets.precompile += %w[tinymce/tiny_mce.js tinymce/langs/en.js tinymce/themes/advanced/editor_template.js]

added in application.js //= require tinymce-jquery

brunomac commented 12 years ago

@ynes are you using it it active admin or by itself in some pages

ynes commented 12 years ago

I also solved by adding <%= tinymce_assets %> to the layout/application.html.erb in order to include < script type="text/javascript" src="/assets/tinymce-c549e88801182a609a4b0c6665fd796c.js" > on the head and then precompiling with:

RAILS_ENV=production bundle exec rake assets:precompile

jasonfb commented 11 years ago

On Heroku, I am adding the list of assets tinymce to config.assets.precompile list (in my case in config/application.rb) like so:

config.assets.precompile += %w[tinymce/tiny_mce.js tinymce/langs/en.js tinymce/themes/advanced/editor_template.js]

but I'm still getting these two errors Failed to load: http://d1o3iv2jf8yo4h.cloudfront.net/assets/tinymce/langs/en.js Failed to load: http://d1o3iv2jf8yo4h.cloudfront.net/assets/tinymce/themes/simple/editor_template.js

are there references to these paths statically? I see some references in the JS but it is minified & obfuscated in what I am looking as so I'm not exactly sure how it works.

Is there a way to get this to work with the Asset pipeline? Serving static assets on heroku is not really an option for us, although I could see about moving these particular assets to be served statically from the public/ folder

any recommendations on how to do this?

bruno commented 11 years ago

I am facing exactly the same problem as @jasonfb and I cannot figure out how to sort out this issue, painful because all our textareas are rendered unusable when the en.js and editor_template.js don't load.

spohlenz commented 11 years ago

@jasonfb Sorry I missed your comment previously.

From what I can gather, the issue is related to the way tinymce-rails copies the asset files. For performance reasons (see https://github.com/spohlenz/tinymce-rails/issues/87#issuecomment-12830162), tinymce-rails bypasses the asset pipeline, instead copying the assets directly. What this means is that the manifest file does not include the TinyMCE assets so those files aren't copied to Cloudfront by asset_sync (this also causes other issues such as #83).

I plan to update the asset copy task to also update the manifest, and hopefully I will get a chance to work on that later this week. Rails 4 complicates things a little, since the manifest format is switching to JSON. I should be able to make it work with both though.

spohlenz commented 11 years ago

I've created a new branch at https://github.com/spohlenz/tinymce-rails/tree/update-manifest which updates the asset manifest when copying the TinyMCE assets over. Could you give it a try and see if it solves the issue?

davesmylie commented 11 years ago

This patch solves the issue for me. Thanks =)

davidguthu commented 11 years ago

This patch doesn't seem to be available any longer, has this code been rolled into the gem? Or where can I see the patch?

spohlenz commented 11 years ago

@davidguthu This has been merged into the master branch now and is available in the latest release 3.5.8.1.

davidguthu commented 11 years ago

I was hoping this would rectify https://github.com/spohlenz/tinymce-rails/issues/91 but apparently it doesn't, do you have any idea what is going on with that issue?