galetahub / ckeditor

Ckeditor 4.x integration gem for rails
https://ckeditor.com/ckeditor-4/
MIT License
2.23k stars 878 forks source link

uninitialized constant Ckeditor::Picture #905

Closed CaioFML closed 3 years ago

CaioFML commented 3 years ago

Hello, guys, I recently upgrade rails to 6 and now I having troubles with models inside module Ckeditor that was generated automatically in ckeditor folder, rails is not finding this classes.

uninitialized constant Ckeditor::Picture

Im using in application.rb: config.autoload_paths += %W[#{config.root}/app/models/ckeditor]

Any thoughts?

tmhr94 commented 2 years ago

@CaioFML Hi, there. You look like completed this issue. How did you solve it?? I still have the same problem on Rails 6.0

pkarjala commented 1 year ago

I am also experiencing the same issue with the CKEditor gem 4.3.0 on Rails 6.1.7.3. Would like to know if there was any fix or other solution, @CaioFML ?

pkarjala commented 1 year ago

FYI, I was finally able to resolve this issue, and ckeditor is now working in our recently updated to Rails 7.0.8 application.

In Rails 6.1 and onward, autoloading does not work (see https://guides.rubyonrails.org/v7.0.0/upgrading_ruby_on_rails.html#autoloading-during-initialization).

The solution for me was to remove the following from my config/application.rb file entirely:

config.autoload_paths += %W(#{config.root}/app/models/ckeditor)

Commenting this line out resulted in the removal of the error message uninitialized constant Ckeditor::Picture as well as the related uninitialized constant Ckeditor::Attachment_File errors.

I hope that this is helpful for others who are trying to troubleshoot this issue; I'm not absolutely certain it will work, but it may help you in finding a solution.