Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Active Storage in Rails 5.2

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?

like image 881
lulalala Avatar asked Apr 13 '18 09:04

lulalala


Video Answer


2 Answers

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.

like image 169
borisaeric Avatar answered Oct 24 '22 06:10

borisaeric


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.

like image 23
MikeRogers0 Avatar answered Oct 24 '22 05:10

MikeRogers0