ruby-on-rails - 编译 Assets 后未生成摘要

标签 ruby-on-rails ruby-on-rails-3

在生产环境中执行rake assets:precompile后,它会显示一条消息

Generated non-digest assets in 485ms

我还尝试了rake assets:precompile:allrake assets:precompile:primary,但它仍然没有生成 Assets 摘要。这是我的 Production.rb 文件。

Gullak2::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

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

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs
  config.assets.digest = true
  config.assets.logger = Logger.new($stdout)
  # Defaults to nil and saved in location specified by config.assets.prefix
  # config.assets.manifest = YOUR_PATH

  # Specifies the header that your server uses for sending files
   config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # See everything in the log (default is :info)
  # config.log_level = :debug

  # Prepend all log lines with the following tags
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server
  # config.action_controller.asset_host = "http://assets.example.com"

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  config.assets.precompile += %w( merchant.css merchant.js)
  config.assets.initialize_on_precompile = false
  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false

  # Enable threaded mode
  # config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify
end 

最佳答案

尝试以下代码:-

task non_digested: :environment do
  assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
  regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
  assets.each do |file|
    next if File.directory?(file) || file !~ regex

    source = file.split('/')
    source.push(source.pop.gsub(regex, '.'))

    non_digested = File.join(source)
    FileUtils.cp(file, non_digested)
  end
end

关于ruby-on-rails - 编译 Assets 后未生成摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21498355/

相关文章:

ruby-on-rails - Rails 是否在当前的 Ruby 进程中运行?

ruby-on-rails - 使用 Stripe::Card 创建一个新的 Stripe::Charge

ruby-on-rails - Ruby on Rails 修改而不是编辑

ajax - Rails 3 - 在ajax表单提交后留在页面上但显示 "flash"

ruby-on-rails - 为什么结果是从数据库而不是缓存加载的?

ruby-on-rails-3 - 导轨 :3 Devise signup Filter chain halted as :require_no_authentication rendered or redirected

ruby-on-rails - Rails 3 给出 URL 中的点的路由错误

ruby-on-rails - 一个名为 "type"的模型属性会自动插入到 ActiveModel::MassAssignmentSecurity::BlackList 中

ruby-on-rails - 您如何指定 Minitest 测试的确切顺序?

ruby-on-rails-3 - 使用 Paperclip 将视频上传到 Heroku - 如何制作缩略图?