spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
813 stars 256 forks source link

ReferenceError: Can't find variable: TinyMCERails #238

Closed AlexandrePerdomo closed 5 years ago

AlexandrePerdomo commented 6 years ago

I'm totally unable to use the gem. Following the instructions step by step, trying each of the 3 ways to include the TinyMCE assets, and still not working. Working on rails 5.0.1.

Also try to follow this guide, with same results : https://alexanderpaterson.com/posts/using-the-tinymce-text-editor-in-a-rails-application

As i'm not able to find a solution (didn't find anything in the issues), i open a new issue.

spohlenz commented 6 years ago

Try clearing out the Sprockets cache (rake tmp:cache:clear) and restarting the Rails server. If that doesn't work, could you upload your progress to a GitHub repo and I'll try to find out what's going wrong.

AlexandrePerdomo commented 6 years ago

I try to clear the Sprockets cache but it didn't change anything. Actually i don't have enough time to create a new app, i will do that as soon as possible. To help, here is my gem file :

source 'https://rubygems.org' ruby '2.3.3' gem 'rails', '5.0.1' gem 'devise' gem 'i18n' gem 'figaro' gem 'cloudinary', '1.1.7' gem 'attachinary', github: 'assembler/attachinary' gem 'jquery-fileupload-rails' gem 'coffee-rails' gem 'gmaps4rails' source 'https://rails-assets.org' do gem 'rails-assets-underscore' end gem 'will_paginate', '~> 3.1.0' gem 'tinymce-rails' gem 'jbuilder', '~> 2.0' gem 'pg', '0.20.0' gem 'puma' gem 'redis' gem 'geocoder' gem 'country_select' gem 'activeadmin' gem 'rails-assets-bootstrap-html5sortable', source: 'https://rails-assets.org' gem 'bootstrap-select-rails' gem 'imagesLoaded_rails' gem 'pundit' gem 'packery-rails' gem 'swiper-rails' gem 'friendly_id', '~> 5.1.0' gem 'aws-sdk' gem 'autoprefixer-rails' gem 'bootstrap-sass' gem 'font-awesome-sass' gem 'jquery-rails' gem 'jquery-ui-rails' gem 'sass-rails' gem 'simple_form' gem 'uglifier' gem 'faker' group :development, :test do gem 'better_errors' gem 'binding_of_caller' gem 'listen', '~> 3.0.5' gem 'pry-byebug' gem 'pry-rails' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end

Already have conflicts between some gems, can this issue be coming for a conflict ?

cowlibob commented 6 years ago

This could be your erb using the <%= tinymce %> helper before the js has loaded. Try adding <%= tinymce_assets %> to the section of the page.

I had the same problem (after a rails upgrade, but that may be coincidental) and options 1 & 2 in the readme (3. Include the TinyMCE assets) didn't help. Option 3 did.

pytrumpeter commented 6 years ago

I have tried all three options and am also getting 'Uncaught ReferenceError: TinyMCERails is not defined'.

Edit: I was on 4.7.9, with Rails 5.1.5. Just dropped back to tinymce-rails version 4.4.3 and it is now working. Updated to 4.7.9 as a sanity check, and it is indeed broken there.

This is using the require tinymce-jquery option.

cowlibob commented 6 years ago

@harveynr Yes, I was on Rails 5.1.5 and 4.7.9 too.

spohlenz commented 6 years ago

I am unfortunately unable to reproduce this. I have created a test application at https://github.com/spohlenz/tinymce-rails-jquery-test (using Rails 5.1.5 and tinymce-rails 4.7.9) that works as expected.

tbhockey commented 6 years ago

I am having the same issue on Rails 4.2.8 and tinymce-rails 4.7.13.

Downgraded to 4.4.3 as suggested by @harveynr and it works again.

Any updates?

noahpatterson commented 5 years ago

Here's some sleuthing. I see this error occur on Rails 5.1.6 at tinymce-rails 4.7.2. 4.7.1 works fine. A note that could help is I'm running tinymce with Simple Form and a custom form element. I can try to do a diff between 4.7.2 and 4.7.3 to see if anything stands out.

Edit: Never mind on looking at the diff. Those JS files are huge and I don't know the codebase like spohlenz would.

Here's my tinymce.yml if that helps narrow down or reproduce the problem:

toolbar1: styleselect | insert | bold italic underline | bullist numlist outdent indent alignleft aligncenter forecolor backcolor | code
toolbar2:
menubar: file edit view table
plugins:
  - table
  - code
  - image
  - media
  - advlist
  - autolink
  - autosave
  - lists
  - link
  - charmap
  - hr
  - searchreplace
  - wordcount
  - visualblocks
  - visualchars
  - fullscreen
  - nonbreaking
  - directionality
  - paste
  - textcolor
  - colorpicker
selector: textarea:not(.no-wysiwyg)
browser_spellcheck: true
advlist_bullet_styles: default
advlist_number_styles: default
spohlenz commented 5 years ago

@noahpatterson Would you be able to put together a basic demo application that exhibits the issue, or steps to reproduce on a fresh application?

nickrivadeneira commented 5 years ago

Ran into the same issue with a very minimalistic tinymce.yml. Reverting to 4.7.1 worked as @noahpatterson said. I'm on rails 5.2.0.

spohlenz commented 5 years ago

It looks like the tutorial at https://alexanderpaterson.com/posts/using-the-tinymce-text-editor-in-a-rails-application is somewhat out of date.

The tinymce-rails gem has its own tinymce.js file which sets up the TinyMCERails module, and by creating app/assets/javascripts/tinymce.js this file is overridden.

If you want to continue with that tutorial, change the file name to something else, e.g. app/assets/javascripts/editor.js.

juraijaree commented 5 years ago

This could be your erb using the <%= tinymce %> helper before the js has loaded. Try adding <%= tinymce_assets %> to the section of the page.

I had the same problem (after a rails upgrade, but that may be coincidental) and options 1 & 2 in the readme (3. Include the TinyMCE assets) didn't help. Option 3 did.

This solved my issue. Though I put <%= tinymce_assets %> in <head>

kartikupadhyay90 commented 3 years ago

It looks like the tutorial at https://alexanderpaterson.com/posts/using-the-tinymce-text-editor-in-a-rails-application is somewhat out of date.

The tinymce-rails gem has its own tinymce.js file which sets up the TinyMCERails module, and by creating app/assets/javascripts/tinymce.js this file is overridden.

If you want to continue with that tutorial, change the file name to something else, e.g. app/assets/javascripts/editor.js.

This worked for me I am using rails 5.0.1

servatti commented 2 years ago

<%= tinymce_assets %> before <%= tinymce %> did the trick.

ankitEkincare commented 1 year ago

This could be your erb using the <%= tinymce %> helper before the js has loaded. Try adding <%= tinymce_assets %> to the section of the page. I had the same problem (after a rails upgrade, but that may be coincidental) and options 1 & 2 in the readme (3. Include the TinyMCE assets) didn't help. Option 3 did.

This solved my issue. Though I put <%= tinymce_assets %> in <head>

Thanks, it helped me also