Rails5 | Uncaught TypeError:$(...)。froalaEditor不是函数

时间:2018-02-10 00:59:20

标签: ruby-on-rails froala

我正在使用rails5.0.6并尝试将Froala编辑器添加到我的项目中。

在开发中它工作正常,但在生产中Froala不起作用,结果是

  

new:107 Uncaught TypeError:$(...)。froalaEditor不是函数

为了解决这个问题,我做了

  • rails assets:预编译rails_env = production
  • 在production.rb中,重写config.assets.compile = true

但我没有解决。

在我的assets / javascripts / application.js中:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require main/bootstrap.min
//= require froala_editor.min.js
//= require plugins/colors.min
//= require plugins/font_size.min
//= require plugins/char_counter.min
//= require languages/ja
//= require_tree ./main

在我的文章/新107中:

<script>
  $(function() {
$('#wysiwyg').froalaEditor({     
  language: 'ja',      
  toolbarButtons: ['bold','strikeThrough','fontSize']
});
});
</script>

在我的config / production.rb中:

Rails.application.configure do
config/application.rb.

  config.cache_classes = true

  config.eager_load = true

config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

  config.assets.js_compressor = :uglifier

  config.assets.compile = true

  config.log_level = :debug

  config.log_tags = [ :request_id ]

  config.action_mailer.perform_caching = false


  if ENV["RAILS_LOG_TO_STDOUT"].present?
    logger           = ActiveSupport::Logger.new(STDOUT)
    logger.formatter = config.log_formatter
    config.logger = ActiveSupport::TaggedLogging.new(logger)
  end

  config.active_record.dump_schema_after_migration = false
end

0 个答案:

没有答案