Rails 4 - 在生产中使用 CDN

Rails 4 - Using CDN in Production

在我的 Rails 4 应用程序中,我使用资产管道来为我的自定义 css/js 文件提供服务。我还使用了几个 cdn 提供商来进行样式设置。在开发中一切正常;然而,当我切换到生产环境并尝试将我的应用程序部署到我的 VPS 时,我的应用程序似乎没有从 CDN 提供商那里获取 css/js 内容。这是我的 app/views/layouts/application.html.haml 的摘录(注意:我使用的是 haml 而不是 erb)

!!!
%html
  %head
    %title Muse
    = stylesheet_link_tag    'application', media: 'all'
    = javascript_include_tag 'application'
    %link{:rel => "stylesheet", :href => "http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css"}
    %link{:rel => "stylesheet", :href => "http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"}
    %link{:rel => "stylesheet", :href => 'http://fonts.googleapis.com/css?family=Roboto:400,300,700'}
    = csrf_meta_tags

我确定我错过了一大步。我四处寻找,发现了许多复杂而矛盾的观点。我希望有人能帮助我并阐明制作 rails 应用程序从生产中的 CDN 获取样式内容的必要条件。

我想我找到了解决办法。这太愚蠢了。只需 运行 您本地计算机上的以下内容

rake assets:precompile RAILS_ENV=production