Skip to content

Commit

Permalink
make autoloader fire in the console and migrations again
Browse files Browse the repository at this point in the history
  • Loading branch information
evan committed Jan 16, 2008
1 parent 4f88f85 commit 77ac121
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/has_many_polymorphs/autoload.rb
@@ -1,5 +1,6 @@

require 'dispatcher'
require 'initializer' unless defined? ::Rails::Initializer
require 'dispatcher' unless defined? ::ActionController::Dispatcher

module HasManyPolymorphs

Expand Down Expand Up @@ -54,6 +55,16 @@ def self.autoload

end

class Rails::Initializer #:nodoc:
# Make sure it gets loaded in the console, tests, and migrations
def after_initialize_with_autoload
after_initialize_without_autoload
HasManyPolymorphs.autoload
end
alias_method_chain :after_initialize, :autoload
end

Dispatcher.to_prepare(:has_many_polymorphs_autoload) do
# Make sure it gets loaded in the app
HasManyPolymorphs.autoload
end

0 comments on commit 77ac121

Please sign in to comment.