Ruby on rails Rails 4.0.13资源url缺少前缀和摘要

Ruby on rails Rails 4.0.13资源url缺少前缀和摘要,ruby-on-rails,url,ruby-on-rails-4,assets,digest,Ruby On Rails,Url,Ruby On Rails 4,Assets,Digest,我已经开始开发rails 4.0.13应用程序,我们正在尝试将资产转移到CDN 问题出现在我们的登台服务器上,生成的url缺少前缀和摘要 Ex: https://xxyyzz.blob.core.windows.net/stylesheets/application.css 在我的本地机器上,使用与登台服务器相同的环境,一切正常 Ex:https://xxyyzz.blob.core.windows.net/c532aef6b12d99b3ce3f05b4fc17c02d8a682b13/app

我已经开始开发rails 4.0.13应用程序,我们正在尝试将资产转移到CDN

问题出现在我们的登台服务器上,生成的url缺少前缀和摘要

Ex
https://xxyyzz.blob.core.windows.net/stylesheets/application.css

在我的本地机器上,使用与登台服务器相同的环境,一切正常

Ex
https://xxyyzz.blob.core.windows.net/c532aef6b12d99b3ce3f05b4fc17c02d8a682b13/application-dd1ee03f18e6ee4df65b6a21d8cfcdeb.css

config/environments/dev_1.rb

...
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compile = false
  config.assets.digest = true
  config.assets.debug = false
  config.assets.version = '1.0'
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_tags = [CustomTagger::USER_TOKEN_LAMBDA, CustomTagger::PROCESS_PID]
  config.cache_store = :redis_store, RedisStores.new.url(db: 3), { expires_in: 1.day, driver: :hiredis }
...
 config.assets.enabled = true

 config.assets.precompile = Proc.new do |filename, path|
   case
   # JS
   when /application-.+\.js/ =~ filename then true
   when filename == 'vendor.js' then true
   # CSS
   when filename.end_with?('master-default.css') then true
   when filename == 'application.css' then true
   # IMG
   when /assets\/images\// =~ path then true
   # Exclude everything else.
   else false
   end
 end
 config.asset_host = 'https://xxyyzz.blob.core.windows.net'

 # Each environment must have a different asset path (the SHA1 digest of
 # Rails.env + Rails.application.revision).
 #
 # See http://guides.rubyonrails.org/configuring.html#rails-general-configuration.
 # See https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L174-L186
 config.after_initialize do
   ActiveSupport.on_load(:action_view) do
     self.assets_prefix = Digest::SHA1.hexdigest(Rails.env + Rails.application.revision)
   end unless Rails.env.development?
 end
 config.autoload_paths += %W(#{config.root}/lib)
 config.middleware.insert_before Rack::Sendfile, 'HttpMethodNotAllowed'
config/application.rb

...
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compile = false
  config.assets.digest = true
  config.assets.debug = false
  config.assets.version = '1.0'
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_tags = [CustomTagger::USER_TOKEN_LAMBDA, CustomTagger::PROCESS_PID]
  config.cache_store = :redis_store, RedisStores.new.url(db: 3), { expires_in: 1.day, driver: :hiredis }
...
 config.assets.enabled = true

 config.assets.precompile = Proc.new do |filename, path|
   case
   # JS
   when /application-.+\.js/ =~ filename then true
   when filename == 'vendor.js' then true
   # CSS
   when filename.end_with?('master-default.css') then true
   when filename == 'application.css' then true
   # IMG
   when /assets\/images\// =~ path then true
   # Exclude everything else.
   else false
   end
 end
 config.asset_host = 'https://xxyyzz.blob.core.windows.net'

 # Each environment must have a different asset path (the SHA1 digest of
 # Rails.env + Rails.application.revision).
 #
 # See http://guides.rubyonrails.org/configuring.html#rails-general-configuration.
 # See https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L174-L186
 config.after_initialize do
   ActiveSupport.on_load(:action_view) do
     self.assets_prefix = Digest::SHA1.hexdigest(Rails.env + Rails.application.revision)
   end unless Rails.env.development?
 end
 config.autoload_paths += %W(#{config.root}/lib)
 config.middleware.insert_before Rack::Sendfile, 'HttpMethodNotAllowed'

还有其他人遇到过这种情况吗?

找到了问题所在

rails似乎会检查文件是否存在于public/assets中,如果不是,则不会设置前缀和摘要

类似问题:

一个可能的解决方案是将manifest.json文件保存在repo中 或者添加仅预编译清单文件的部署任务。

是否
config/environments/dev_1.rb
是您的登台服务器的环境文件?我假设是这样,但您提到了两个环境,但您的帖子只包含一个文件(其名称与任何一个都不匹配)。我认为只要你有
config.assets.digest=true
,你就应该得到指纹识别。是的,dev_1是使用的环境。我不知道你对两种环境的印象是什么。我还认为config.assets.digest=true应该添加指纹…哦,很抱歉,我错过了这是一个环境,在本地和远程服务器上的工作方式不同。听起来像是部署问题。。。您确定本地服务器上的所有内容都在您的存储库中,并且已按预期部署到远程服务器上吗?是的,我添加了记录器以检查配置/环境值,所有内容似乎都是一样的。也可以从rails控制台进行检查。