【问题标题】:Precompiled assets Images from gems not found未找到来自 gem 的预编译资产图像
【发布时间】:2016-04-06 21:52:42
【问题描述】:

我的 Rails 应用在生产环境中找不到来自 gem 的预编译图像。所有其他资产都在工作,所有资产都在开发中。在生产模式下运行时出现以下错误;

ActionController::RoutingError (No route matches [GET] "/assets/dataTables/sort_asc.png"):

资产似乎已正确预编译,显示来自 app/assets/images 的图像。

有人能解释一下这个问题吗?

【问题讨论】:

标签: ruby-on-rails


【解决方案1】:

重新编译资产对我有用。

删除公共/资产

1.rake assets:clobber RAILS_ENV=production

资产编译

2.rake assets:precompile RAILS_ENV=production

3.重启服务器,例如(nginx)

感谢 albert.qing 的回答 here

我可能会补充说我正在使用 docker,所以我在 docker 文件的末尾添加了这一步

/Dockerfile

FROM ruby:2.2.3-slim
.
.
.
# Precompile Rails assets
RUN bundle exec rake assets:clobber RAILS_ENV=production
RUN bundle exec rake assets:precompile RAILS_ENV=production
.
.
.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    • 2012-12-21
    • 2011-11-30
    • 2020-01-12
    • 2014-07-24
    相关资源
    最近更新 更多