Last Updated: February 25, 2016
·
2.073K
· h3h

Disabling RailsAdmin rake task warning

By default the rails_admin gem will output a warning when you have it installed and are running rake tasks in your project:

[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.

This is undesirable for me, especially when less technical teammates are running simple tasks and it looks like something has gone wrong. To get around this, I simply clear and redefine the rake task in my project, taken directly from their rails_admin.rake, without their confusing puts statement:

lib/tasks/rails_admin.rake:

Rake::Task["rails_admin:disable_initializer"].clear
namespace :rails_admin do
  desc "Disable rails_admin initializer"
  task :disable_initializer do
    if ENV['SKIP_RAILS_ADMIN_INITIALIZER'].nil?
      ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = 'true'
    end
  end
end