jemcode / administrate-field-ckeditor

A plugin for adding CKEditor support to Administrate
https://rubygems.org/gems/administrate-field-ckeditor
MIT License
20 stars 25 forks source link

Heroku deploy issue #13

Closed AndreiMotinga closed 6 years ago

AndreiMotinga commented 6 years ago

Hey folks, thank you for the gem.

I'm trying to deploy new and shiny rails 5.2 api only app to Heroku. I added administrate and administrate-field-ckeditor.

Deploy succeeds, but app can't start with

...
2018-04-22T02:39:32.250563+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2018-04-22T02:39:34.886038+00:00 app[web.1]: [4] * Version 3.11.4 (ruby 2.4.1-p111), codename: Love Song
2018-04-22T02:39:34.886023+00:00 app[web.1]: [4] Puma starting in cluster mode...
2018-04-22T02:39:34.886045+00:00 app[web.1]: [4] * Min threads: 5, max threads: 5
2018-04-22T02:39:34.886046+00:00 app[web.1]: [4] * Environment: production
2018-04-22T02:39:34.886049+00:00 app[web.1]: [4] * Preloading application
2018-04-22T02:39:34.886048+00:00 app[web.1]: [4] * Process workers: 1
2018-04-22T02:39:38.100005+00:00 app[web.1]: [4] ! Unable to load application: NoMethodError: undefined method `layout' for Ckeditor::ApplicationController:Class
2018-04-22T02:39:38.100115+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.4.0/bin/puma)
2018-04-22T02:39:38.100250+00:00 app[web.1]: NoMethodError: undefined method `layout' for Ckeditor::ApplicationController:Class
2018-04-22T02:39:38.100254+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/ckeditor-4.2.4/app/controllers/ckeditor/application_controller.rb:2:in `<class:ApplicationController>'
2018-04-22T02:39:38.100255+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/ckeditor-4.2.4/app/controllers/ckeditor/application_controller.rb:1:in `<main>'
....

There aren't much of the docs to go by... and since It's only API mode, I'm not sure what to do about the 'layout' thing. Was hoping you can provide some valuable input.

Best, Andrei

AndreiMotinga commented 6 years ago

~UPDATE:~ skip to UPDATE 2

It seems ckeditor needs ApplicationController to render layout. Workaround is to create application controller that inherits from base, as in

class ApplicationController < ActionController::Base
end

and create separate controller for api use, as in

class ApiController < ActionController::API
end

and use it for api controllers. I suppose it's more of a ckeditor in general issue than of this gem.

UPDATE 2: Better workaround

ckeditor provides way to set controller to use, so in case of using api only mode and administrate gem you can create config/initializers/ckeditor.rb with

Ckeditor.setup do |config|
  config.parent_controller = "Admin::ApplicationController"
end

This way you can keep your api controllers intact.

rikkipitt commented 6 years ago

Thanks for raising this issue @AndreiMotinga, hopefully it'll help future Googlers!

Cheers, Rikki