Disable Active Storage in Rails 5.2

风流意气都作罢 提交于 2019-11-30 06:43:07

问题


Upgrading Rails to 5.2, and I found out that I must commit the storage.yml into version control. I don't plan to use ActiveStorage. Is there a way to disable it?


回答1:


Remove next line from config/application.rb

require "active_storage/engine"

Remove next line from environments config/environments/*.rb

config.active_storage.service = :local

Remove next line from app/assets/javascripts/application.js

//= require activestorage

ActiveStorage rails routes will vanish

In case there is statement require 'rails/all' in application.rb then you can use solution provided below where you need to require dependency by dependency and to omit active_storage.




回答2:


The only solution I've found so far is in config/application.rb, replacing:

require 'rails/all'

With:

require "rails"

# Include each railties manually, excluding `active_storage/engine`
%w(
  active_record/railtie
  action_controller/railtie
  action_view/railtie
  action_mailer/railtie
  active_job/railtie
  action_cable/engine
  rails/test_unit/railtie
  sprockets/railtie
).each do |railtie|
  begin
    require railtie
  rescue LoadError
  end
end

which is taken from Rails' source.




回答3:


Remove lines like the following from config/environments/*.rb

config.active_storage.service = :local

Rails will then not load the yaml file.




回答4:


If your problem is with deploy to Heroku, I found that making sure that the database adapter is postgres can solve the problem. Change the production section of config/database.yml to:

production:
  adapter: postgresql
  encoding: unicodeubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  database: myapp_production
  username: myapp
  password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>


来源:https://stackoverflow.com/questions/49813214/disable-active-storage-in-rails-5-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!