【发布时间】:2015-05-04 15:05:54
【问题描述】:
我在生产环境中使用 Ckeditor 时遇到问题。
我有 2 个环境,暂存和生产,它们都在 Heroku 中。
我可以在暂存环境中看到 Ckeditor,但看不到 prod。
我的配置如下: 配置/环境/production.rb:
# Precompile additional assets
config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w( *.js )
config.assets.precompile += %w( .svg .eot .woff .ttf )
config/initializers/assets.rb:
Rails.application.config.assets.precompile += %w( ckeditor/* )
app/assets/javascripts/application.js:
//= require ckeditor/init
(基本上遵循https://github.com/galetahub/ckeditor 文档)
环境暂存和生产都使用 RAILS_ENV=production。
我使用 Amazon S3 为我的资产提供服务,这很好,因为我可以看到生产中存在 javascript 功能、图标和图像。
我在这里有什么明显的遗漏吗?
谢谢!
P.S:我正在使用 RoR 4.2 和 ckeditor 4.1.1
编辑:
1 - 我验证了在两个环境中提供的 javascript,并且文件是相同的!和 Ckeditor javascript 代码都存在于两者中。所以问题不在于资产预编译,而是其他问题......
2 - ckeditor.js 文件存在于存储桶中,但我仍然收到来自服务器的 404 not found 响应。该文件位于 assets/ckeditor/ckeditor-xxxx.js 下
【问题讨论】:
-
您说 javascripts 文件在 Prod 中提供。那么,您是否收到 JS 错误?我遇到了完全相同的问题,但它与资产编译有关。
-
是的,经过调查,似乎在资产中找不到文件 public/assets/ckeditor/ckeditor-xxxx.js。我不确定我应该如何包含它,因为 prod 和 staging 具有完全相同的配置(S3 存储桶除外)
-
您可以尝试预编译资产,看看它是否会修复它。 RAILS_ENV=development bundle exec rake assets:precompile 我知道这不是一个修复程序,但实际上我最终为我的一个项目这样做了。
-
@Yosep:我终于可以修好了!检查答案。
标签: javascript ruby-on-rails heroku assets