当我运行heroku运行rake数据库时出现此错误:在生产中迁移 [英] I get this error when i run heroku run rake db:migrate in production

查看:179
本文介绍了当我运行heroku运行rake数据库时出现此错误:在生产中迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行heroku运行rake db时,出现此错误:在生产中迁移。
DEPRECATION警告: config.serve_static_files 已弃用,并将在Rails 5.1中删除。
请改用 config.public_file_server.enabled = true
(在/app/config/environments/production.rb:25中调用block)

我在这里尝试了一些解决方案,但是我可以' t解决问题。

这是我的production.rb文件



  Rails.application.configure do#这里指定的设置优先于config / application.rb中的设置。 #代码不会在请求之间重新加载。 config.cache_classes = true#启动时加载代码。这种渴望将大多数Rails和#应用程序加载到内存中,允许线程Web服务器#和那些依赖写入时复制的服务器执行得更好。 #Rake任务会自动忽略此选项的性能。 config.eager_load = true#完全错误报告被禁用并且缓存打开。 config.consider_all_requests_local = false config.action_controller.perform_caching = true#启用Rack :: Cache在应用程序前放置一个简单的HTTP缓存#在启用此缓存之前,将`rack-cache`添加到您的Gemfile中。 #对于大规模生产使用,请考虑使用缓存逆向代理,如#NGINX,清漆或鱿鱼。 #config.action_dispatch.rack_cache = true#默认情况下禁止从`/ public`文件夹中提供静态文件,因为#Apache或NGINX已经处理了这个文件。 config.serve_static_files = ENV ['RAILS_SERVE_STATIC_FILES']。present? #压缩JavaScript和CSS。 config.assets.js_compressor =:uglifier#config.assets.css_compressor =:sass#如果预编译的资源丢失,不要回退到资产管道。 config.assets.compile = true#资产摘要允许您为所有资产设置远期HTTP过期日期,#但仍可通过摘要参数过期。 config.assets.digest = true#`config.assets.precompile`和`config.assets.version`已移至config / initializers / assets.rb#指定服务器用于发送文件的标头。 #config.action_dispatch.x_sendfile_header ='X-Sendfile'#for Apache#config.action_dispatch.x_sendfile_header ='X-Accel-Redirect'#for NGINX#强制通过SSL访问应用程序,使用Strict-Transport-Security,以及使用安全的cookie。 config.force_ssl = true#使用最低日志级别来确保问题出现时诊断信息#的可用性。 config.log_level =:debug#在所有日志行上加上以下标签。 #config.log_tags = [:subdomain,:uuid]#使用不同的记录器进行分布式设置。 #config.logger = ActiveSupport :: TaggedLogging.new(SyslogLogger.new)#在生产中使用不同的缓存存储。 #config.cache_store =:mem_cache_store#启用来自资产服务器的图片,样式表和JavaScript的服务。 #config.action_controller.asset_host ='http://assets.example.com'#忽略不良的电子邮件地址,不要引发电子邮件传递错误。 #将其设置为true并配置电子邮件服务器以立即投递,以引发投递错误。 #config.action_mailer.raise_delivery_errors = false#为I18n启用语言环境回退(当无法找到翻译时,查找任何语言环境回落到#the I18n.default_locale)。 config.i18n.fallbacks = true#发送弃用声明给已注册的侦听器。 config.active_support.deprecation =:notify#使用默认日志记录格式化程序,以便不抑制PID和时间戳记。 config.log_formatter = :: Logger :: Formatter.new#迁移后不要转储模式。 config.active_record.dump_schema_after_migration = falseend  


解决方案

是的,用这个替换弃用的代码:

  config.public_file_server.enabled = ENV ['RAILS_SERVE_STATIC_FILES']。当下? 

来源: https://devcenter.heroku.com/articles/getting-started-with-rails5#heroku-gems


I get this error when i run heroku run rake db:migrate in production. DEPRECATION WARNING: config.serve_static_files is deprecated and will be removed in Rails 5.1. Please use config.public_file_server.enabled = true instead. (called from block in at /app/config/environments/production.rb:25)

I have tried some solution here on stackoverflow but i can't fix the problem.

Here is my production.rb file

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 = true

  # 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?

  # 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 = true

  # 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

  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

  # 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

  # Use the lowest log level to ensure availability of diagnostic information
  # when problems arise.
  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'

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

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

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

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  # Do not dump schema after migrations.
  config.active_record.dump_schema_after_migration = false
end

解决方案

Yes, replace the deprecated code with this:

 config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

Source: https://devcenter.heroku.com/articles/getting-started-with-rails5#heroku-gems

这篇关于当我运行heroku运行rake数据库时出现此错误:在生产中迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆