Why do I get MIME type ('text/html') is not executable error for ckeditor rails gem on image uploads?

828 views Asked by At

When I go to edit a resource I get the above error for config.js and then when I go to view the resource I get it too. Also all my image uploads are broken urls when I go to view them in the actual post and when I go to the backend and edit the resource I click 'browser server' on image upload button and all images that were previously uploaded show as broken image links.

Here is my setup:

Rails 4 Paperclip image handling ckeditor ckeditor (4.0.10)

/models/ckeditor/picture.rb

class Ckeditor::Picture < Ckeditor::Asset
  has_attached_file :data,
                    :url  => "/ckeditor_assets/pictures/:id/:style_:basename.:extension",
                    :path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",
                    :styles => { :content => '800>', :thumb => '118x100#' }

  validates_attachment_size :data, :less_than => 2.megabytes
  validates_attachment_presence :data
  do_not_validate_attachment_file_type :data

  def url_content
    url(:content)
  end
end

/config/initializers/ckeditor.rb

Ckeditor.setup do |config|
  # ==> ORM configuration
  # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
  # available as additional gems.
  require "ckeditor/orm/active_record"

  # Allowed image file types for upload.
  # Set to nil or [] (empty array) for all file types
  # config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]

  # Allowed attachment file types for upload.
  # Set to nil or [] (empty array) for all file types
  # config.attachment_file_types = ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "swf"]

  # Setup authorization to be run as a before filter
  # config.authorize_with :cancan

  # Asset model classes
  # config.picture_model { Ckeditor::Picture }
  # config.attachment_file_model { Ckeditor::AttachmentFile }

  # Paginate assets
  # config.default_per_page = 24
end

/config/application.rb

module PopupHub
  class Application < Rails::Application

    config.exceptions_app = self.routes

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    config.nav_lynx.selected_class = 'current'

    config.assets.paths << Rails.root.join('app', 'assets', 'fonts')

    config.assets.paths << Rails.root.join('app', 'assets', 'font-awesome')

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

    config.assets.initialize_on_precompile = false
    config.assets.precompile += %w( style.css *.scss *.js *.woff *.ttf )

  end
end

error when editing a resource in console

Refused to execute script from '/assets/ckeditor/config-65b33bedd052d521bd0b685fa5bb9800.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

When viewing textarea

This is what I see

Then when I try to access the Browse Images area I get this:

enter image description here

When I go and check on the server, the folders these images are meant to be uploaded to are missing or not there at all and I do not know why that would happen at all.

Has anyone ever experienced this?

0

There are 0 answers