Javascript Rails 5:JS文件未在生产中加载

Javascript Rails 5:JS文件未在生产中加载,javascript,ruby-on-rails,ruby-on-rails-5,x-editable,Javascript,Ruby On Rails,Ruby On Rails 5,X Editable,我正在使用Rails 5和Ruby 2.5,并部署到Amazon Elastic Beanstalk 所有样式表和CSS文件都在生产环境中正确加载,但是Javascript文件在生产环境中没有正确加载。在开发过程中,一切都很完美 我认为问题在于,在生产中,我只看到一个.js文件,它将许多javascript文件塞进了一起,这使得它无法正确加载 这是它在本地主机上的外观: 这就是它在生产服务器上的外观: 当我搜索production.js文件时,我丢失了很多本地主机上加载的单独js文件中的代码

我正在使用Rails 5和Ruby 2.5,并部署到Amazon Elastic Beanstalk

所有样式表和CSS文件都在生产环境中正确加载,但是Javascript文件在生产环境中没有正确加载。在开发过程中,一切都很完美

我认为问题在于,在生产中,我只看到一个.js文件,它将许多javascript文件塞进了一起,这使得它无法正确加载

这是它在本地主机上的外观:

这就是它在生产服务器上的外观:

当我搜索production.js文件时,我丢失了很多本地主机上加载的单独js文件中的代码

我已经尝试运行了
RAILS\u ENV=production bundle exec rake assets:clean assets:precompile
,我可以在/public/assets文件夹中看到我的所有资产

My production.rb文件:

Rails.application.configure do
    config.cache_classes = true
    config.eager_load = true
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true
    config.read_encrypted_secrets = true
    config.public_file_server.enabled = true
    config.assets.js_compressor = :uglifier
    config.assets.compile = false
    config.log_level = :debug
    config.log_tags = [ :request_id ]
    config.action_mailer.perform_caching = false
    config.i18n.fallbacks = true
    config.active_support.deprecation = :notify
    config.log_formatter = ::Logger::Formatter.new

    if ENV["RAILS_LOG_TO_STDOUT"].present?
        logger           = ActiveSupport::Logger.new(STDOUT)
        logger.formatter = config.log_formatter
        config.logger    = ActiveSupport::TaggedLogging.new(logger)
    end

    config.active_record.dump_schema_after_migration = false
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true

    config.assets.digest = true
    Rails.application.config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb )

end
My application.js文件:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require editable/bootstrap-editable
//= require editable/bootstrap2-editable
//= require editable/rails
//= require_tree .
可编辑的
gem用于就地编辑

更新

以下是在application.html.erb文件中加载样式表和Java脚本的方式:

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

尝试
config.assets。将
false
编译为
true
,然后如下所示

config.assets.compile = true

希望它能工作

我解决了这个问题,只需手动下载开发中源代码中出现的每个JS文件,然后将它们上传到服务器,并在代码中手动一个接一个地导入,如locahost屏幕截图所示

尝试在本地计算机上的production env中运行应用程序。它会帮你更多。我认为合并多个文件是在js压缩时编写的。您在web控制台上有任何js错误吗?没有,奇怪的是,我在web控制台上没有任何js错误,在dev和prod.config.assets.paths@rohankharvi中都没有。我尝试将其添加到application.rb,但不幸的是没有任何更改。您是否尝试在未指定env的情况下运行rake?