Javascript 为什么CKEDITOR上传的图片在rails生产站点中出现404错误?
我使用的是ckeditor,在生产站点上传图像时,这很好,但当我更改站点并使用Capistrano部署时,会显示404个图像错误 在我的发言中: production.rb我有: 然后在我的 application.js 在我的 lib/tasks/ckeditor.rake我有:Javascript 为什么CKEDITOR上传的图片在rails生产站点中出现404错误?,javascript,ruby-on-rails,ruby,ckeditor,capistrano,Javascript,Ruby On Rails,Ruby,Ckeditor,Capistrano,我使用的是ckeditor,在生产站点上传图像时,这很好,但当我更改站点并使用Capistrano部署时,会显示404个图像错误 在我的发言中: production.rb我有: 然后在我的 application.js 在我的 lib/tasks/ckeditor.rake我有: 有人知道这一错误的原因吗?这是因为CKEditor gem存储资产的位置不在所有版本共享的符号链接文件夹中。在“我的设置”“公用/系统”中,是指向所有生产版本共享的共享文件夹的符号链接。当管理员通过CKeditor上
有人知道这一错误的原因吗?这是因为CKEditor gem存储资产的位置不在所有版本共享的符号链接文件夹中。在“我的设置”“公用/系统”中,是指向所有生产版本共享的共享文件夹的符号链接。当管理员通过CKeditor上传图像时,需要将其放入该文件夹中,以便共享。我通过在
/models/Ckeditor/attachment_file.rb
在该文件中,我有:
has_attached_file :data,
:url => "/system/ckeditor_assets/attachments/:id/:filename",
:path => ":rails_root/public/system/ckeditor_assets/attachments/:id/:filename"
def store_dir
"public/system/ckeditor_assets/attachments/#{model.id}"
end
将ckeditor文件移动到我的符号链接系统文件夹中,以便在不同版本之间共享。对于Ckeditor::Picture
这可能不是首选方法,但希望能引导您朝着正确的方向前进。这样的图像的URL是什么?您希望URL是什么?我需要将其添加到Capistrano设置中吗?我知道我已经有了系统文件夹。在部署中,该文件夹在生产时是否会被预编译忽略?
//= require ckeditor/override
//= require ckeditor/init
require 'fileutils'
desc "Create nondigest versions of all ckeditor digest assets"
task "assets:precompile" do
fingerprint = /\-[0-9a-f]{32}\./
for file in Dir["public/assets/ckeditor/**/*"]
next unless file =~ fingerprint
nondigest = file.sub fingerprint, '.'
FileUtils.cp file, nondigest, verbose: true
end
end
has_attached_file :data,
:url => "/system/ckeditor_assets/attachments/:id/:filename",
:path => ":rails_root/public/system/ckeditor_assets/attachments/:id/:filename"
def store_dir
"public/system/ckeditor_assets/attachments/#{model.id}"
end