gpt4 book ai didi

ruby-on-rails - Rails 5 Assets 未在生产中加载

转载 作者:数据小太阳 更新时间:2023-10-29 07:58:42 27 4
gpt4 key购买 nike

我最近在我的 Rails 应用程序中更新了一些包,现在我的 Assets 没有被提供。相反,我收到以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found)

我的 Assets 是预编译的:

assets.rb

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += %w(ckeditor/*)
Rails.application.config.assets.precompile += %w(ckeditor/config.js)
Rails.application.config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb )

application.rb

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)


module DeployTest
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w( ckeditor/* )
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
config.active_record.default_timezone = :local
config.time_zone = 'Eastern Time (US & Canada)'
end
end

在告诉我打开编译我的 Assets 之前,请理解这是一个horrible idea .感谢您的任何建议

更新:我通过添加让它工作:

  config.assets.digest = true

到我的 config/environments/staging.rb 文件。奇怪我以前怎么不需要它

最佳答案

有时您需要在 staging.rb 或任何您希望更改反射(reflect)的环境中添加这两种配置。

config.assets.compile = true #set to false by default
config.assets.digest = true

关于ruby-on-rails - Rails 5 Assets 未在生产中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42545262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com