How to regenerate config/application.rb in Rails 4.2?

Hi all,

I’ve been trying to find out if Rails 4.2 provides a single command that regenerates config/application.rb in an existing application.

I’m trying to find something more lightweight than running ‘rails new MyApp’ in a new directory and copying over the file.

The reason I ask is imagine a Rails app is ‘rails new’-ed without the --skip-test-unit option.

Then at a much later date, this app is switched to RSpec. Can config/application.rb be regenerated as if the --skip-test-unit option had been supplied originally to ‘rails new …’?

All this would effectively do is change the require statements near the top of config/application.rb file from:

require ‘rails/all’



Pick the frameworks you want:

require “active_model/railtie”
require “active_job/railtie”
require “active_record/railtie”
require “action_controller/railtie”
require “action_mailer/railtie”
require “action_view/railtie”
require “sprockets/railtie”

require “rails/test_unit/railtie”


It’s possible to get part of the way there with this command:

bin/rake rails:update:configs


Which asks if you want to overwrite config/application.rb and generates a new copy. However, I’ve not been successful in getting that command to make use of the --skip-test-unit option. I’ve tried variations on this without luck:

bin/rake rails:update:configs[–skip-test-unit]


Many thanks in advance for any help,


I don’t know of a command to do that, so I keep the expanded version in a snippet in my editor :frowning:

well, if that snippet is all you want, you can just

cat $(bundle show rails)/railties/lib/rails/all.rb

and copy whatever you need to your config/application.rb