gpt4 book ai didi

ruby-on-rails - Rails CKEditor Gem 给出 404

转载 作者:行者123 更新时间:2023-12-02 01:54:39 26 4
gpt4 key购买 nike

我正在使用这个 CKEditor gem:https://github.com/galetahub/ckeditor

我已经按照 README 中的说明进行操作,但是当我尝试放置一个 f.cktext_area 时,我得到了一些 404:

GET http://localhost:5000/ckeditor/config.js?t=DAED 404 (Not Found) ckeditor.js?body=1:78
GET http://localhost:5000/ckeditor/skins/moono/editor.css?t=DAED 404 (Not Found) ckeditor.js?body=1:78
GET http://localhost:5000/ckeditor/lang/en.js?t=DAED 404 (Not Found) ckeditor.js?body=1:78
Uncaught TypeError: Cannot set property 'dir' of undefined ckeditor.js?body=1:214

我已经运行了 rails generate ckeditor:install --orm=active_record --backend=papercliprake db:migrate

config.autoload_paths += %W(#{config.root}/app/models/ckeditor)application.rbmount Ckeditor::Engine => '/ckeditor' 位于 routes.rb并且 //= require ckeditor/init 在我的 JS 中...

我也重新启动了我的开发服务器,但我仍然收到这些 404。

在我的rake routes中:

ckeditor        /ckeditor                       Ckeditor::Engine

Routes for Ckeditor::Engine:
pictures GET /pictures(.:format) ckeditor/pictures#index
POST /pictures(.:format) ckeditor/pictures#create
picture DELETE /pictures/:id(.:format) ckeditor/pictures#destroy
attachment_files GET /attachment_files(.:format) ckeditor/attachment_files#index
POST /attachment_files(.:format) ckeditor/attachment_files#create

我错过了什么吗?

编辑

我应该补充一点,localhost:5000/assets/ckeditor/config.js 确实可以正常工作,其余的都以 /assets/ 开头...为什么不呢ckeditor.js 使用正确的 Assets 路径?

最佳答案

我不记得我在哪里找到解决方案(Github 问题线程上的某人)。

这对我有用:

添加此 /lib/tasks/ckeditor.rake:

require 'fileutils'

desc "Create nondigest versions of all ckeditor digest assets"
task "assets:precompile" => :environment do
fingerprint = /\-([0-9a-f]{32})\./
for file in Dir["public/assets/ckeditor/**/*"]
# Skip file unless it has a fingerprint
next unless file =~ fingerprint

# Get filename of this file without the digest
# (example) public/assets/ckeditor/config.js
nondigest = file.sub fingerprint, '.'

# Create a filename relative to public/assets
# (example) public/assets/ckeditor/config.js => ckeditor/config.js
filename = nondigest.sub 'public/assets/', ''
filename = filename.sub /.gz$/, '' # Remove .gz for correct asset checking

# Fetch the latest digest for this file from assets
latest_digest = Rails.application.assets.find_asset(filename).try(:digest)

# Debug information
puts '---- ' + file + ' ----'

# Compare digest of this file to latest digest
# [1] is the enclosed capture in the fingerprint regex above
this_digest = file.match(fingerprint)[1]
if (this_digest == latest_digest)
# This file's digest matches latest digest, copy
puts 'Matching digest, copying ' + file
FileUtils.cp file, nondigest, verbose: true
else
# This file's digest doesn't match latest digest, ignore
puts 'Latest digest: ' + latest_digest
puts 'This digest: ' + this_digest
puts 'Non-matching digest, not copying ' + file
end

# Debug information
puts '---- end ----'
end
end

关于ruby-on-rails - Rails CKEditor Gem 给出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20932996/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com