【问题标题】:Rails Ubuntu/passenger/capistrano app assets not deployingRails Ubuntu/passenger/capistrano 应用程序资产未部署
【发布时间】:2016-03-07 12:41:53
【问题描述】:

我的所有资产都不再随更改而更新。我使用与以前相同的设置,但现在当我更改任何“.html.erb”文件或“.scss”文件时,当我将它们添加到 git 并部署时它们不会显示他们与capistrano。知道这可能会发生什么吗?

也许我应该在要部署到的远程服务器上重新安装所有内容?

我正在使用:
Rails 4.2.5.1
红宝石2.2.3p173

生产.rb:

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = false

  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like
  # NGINX, varnish or squid.
  # config.action_dispatch.rack_cache = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
  #config.serve_static_files = false

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  #config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false
  config.assets.initialize_on_precompile = false

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true
end  

我还使用RAILS_ENV=production rake asssets:precompile 在部署资产之前对其进行编译。

【问题讨论】:

  • 尝试将 config.assets.compile 更改为 true 和 config.assets.precompile = [' .js', ' *.scss', '.css']跨度>
  • 在 .js 和 .css 前需要一个星号,但由于某种原因堆栈没有读取这些。

标签: ruby-on-rails git capistrano asset-pipeline


【解决方案1】:

您可以尝试在本地预编译资产,提交然后再次部署。

rake assets:precompile

这不是最佳做法,但我以前在需要时做过。还要在部署期间检查堆栈跟踪。通常,您的 css 或 js 中的某个地方存在错误,导致您的资产无法编译。

【讨论】:

  • 我已经尝试了 rake assets:precompile 没有 rails_env=production。但遇到同样的问题。我将检查我的跟踪,看看我在编译期间是否从资产中得到任何错误。谢谢。 @toddmetheny
  • 当我在本地运行时,我不断收到:App 12242 stderr: autoprefixer: /Users/coreyvincent/Desktop/Applications/RailsApp/app/assets/stylesheets/application.scss:38487:3: Gradient has outdated direction syntax. New syntax is like 'to left' instead of 'right'. 这意味着什么......? @toddmetheny
  • 是的——这意味着你的 scss 中有一个错误,导致你的资产无法编译。您需要找到并调试该错误。
  • 我确实最终修复了这些问题,现在一切都重新部署并且应用程序在本地运行良好。但是在我部署到的服务器上,现在没有任何样式出现。完全没了。 :(@toddmetheny
猜你喜欢
  • 2014-12-10
  • 2016-04-06
  • 2016-06-19
  • 1970-01-01
  • 2013-04-29
  • 1970-01-01
  • 2023-04-06
  • 2013-10-22
  • 1970-01-01
相关资源
最近更新 更多