dispatcher should only be loaded if ActionController is defined

I was trying to create an environment where only ActiveRecord and ActionMailer were loaded but it failed on the last step.

The dispatcher is loaded even if ActionController is not defined. To fix it I just needed to add the line below to railties/lib/ initializer.rb, on the prepare_dispatcher method, around line 480:

  return unless configuration.frameworks.include?(:action_controller)

So we have:

def prepare_dispatcher   return unless configuration.frameworks.include?(:action_controller)   require 'dispatcher' unless defined?(::Dispatcher)   Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)

Dispatcher.new(RAILS_DEFAULT_LOGGER).send :run_callbacks, :prepare_dispatch end

Ticket at: