RailsAdmin Could not load model while using Clockwork and CKEditor

1.3k Views Asked by At

I'm currently getting 2 errors. The one in the logs includes:

[RailsAdmin] Could not load model Clock, assuming model is non existing.

The other is when I run the tests to access rails_admin:

wrong number of arguments (2 for 0)

Using rails 4.2.2 and ruby 2.2.1

I installed the clockwork gem and required it to false.

gem "clockwork", require: false

My clock file is in the lib folder and working properly:

require File.expand_path('../../config/boot',        __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'clockwork'

include Clockwork

if ENV.fetch("CLOCKWORK_ENABLED", false) == "enabled"
  every(1.week, "send reminder warning email", at: "Thursday 06:00", tz: "PST"){
    `rake inactive_user_management:reminder_warning_email`
  }
end

Here is my rails_admin initializer. The error was previously happening on the ckeditor loop and saying there were 2 for 0 arguments for configure: content, :ck_editor.

RailsAdmin.config do |config|
  config.authorize_with do
    unless current_user.admin?
      redirect_to(
        main_app.root_path,
        alert: I18n.t("rails_admin.not_permitted")
      )
    end
  end

  config.current_user_method { current_user }
  config.actions do
    dashboard                     # mandatory
    index                         # mandatory
    new
    export
    bulk_delete
    show
    edit
    delete
    show_in_app

    ## With an audit adapter, you can add:
    # history_index
    # history_show
  end

  RailsAdmin.config do |config|
    config.model Article do
      configure :content, :ck_editor
    end
  end
end

I came across where the error is happening in Rails Admin, but not sure how to solve it the proper way: https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/abstract_model.rb#L20

Thank you for any solves!

2

There are 2 best solutions below

0
On

Instead of configure try to define ckeditor under field. Something like:

  config.model 'Article' do
    edit do
      field :content do
        ckeditor do
          true
        end
      end
    end
  end

Since Clock is not a ActiveRecord model the other error sound legitimate. I am guess rails_admin will continue to render ignoring the load of Clock model.

0
On

I moved the clock.rb into the root folder, updated the required file paths of the application and updated the procfile for the clock.rb's new location.

It fixed the problem.