Robot Has No Heart

Xavier Shay blogs here

A robot that does not have a heart

Speeding up Rails Initialization

Chad Wooley just posted a tip to get rails starting up faster. Which is real, except it doesn’t work if you’re using ActiveScaffold. This is due to a load ordering problem – ActiveScaffold monkey patches the Resource class used by routes after routes have been parsed the first time, and relies on the re-parsing triggered by the inflections change.

To fix this, you can explicitly require the monkey patch just before you draw your routes (it doesn’t depend on anything else in ActiveScaffold).

1
2
3
4
5
6
7
# config/routes.rb
ActionController::Routing::Routes.draw do |map|
  # Explicitly require this, otherwise it won't get loaded before we parse our resources time
  require 'vendor/plugins/active_scaffold/lib/extensions/resources.rb'

  # Your routes go here...
end

Yes it’s a hack on top of hack, but I get my console 30% quicker, so I’m running with it.

Tested on 2.0.2

  1. Thomas says:

    Hey, I have been reading this article, the link doesn't work anymore,

    however i am using rails_admin and I would like to know if I could do something similar to speed up booting rails a bit.

  2. Xavier Shay says:

    No, this was for a way old version of Rails, it's no longer appropriate.

    Maybe start at Speeding Up Rails Startup Time and finish at Skaes' RVM patchsets

Post a comment


(lesstile enabled - surround code blocks with ---)

A pretty flower Another pretty flower