Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9582 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

railties, support multiple Configuration#after_initialize blocks

Reported by: zdennis Assigned to: core
Priority: normal Milestone: 1.x
Component: Railties Version: edge
Severity: normal Keywords:
Cc:

Description

The attached patch adds the ability to add multiple Configuration#after_initialize blocks. Currently you can only have one, and if you define more then one only the last one set is going to be run.

This adds more flexibility at basically no cost for rails developers and plugin developers to be able to add their own custom hook code to the after initialization process.

Example of what this patch does:

# in environment.rb
Rails::Initializer.run do |config|
  after_initialize do
    # this is called
  end
end

# in a development.rb, test.rb or production.rb
config.after_initialize do
  # this is also called
end

# in a plugin's init.rb file
config.after_initialize do
  # this is also called
end 

Attachments

railties_after_initialize.diff (4.2 kB) - added by zdennis on 09/18/07 00:47:54.
railties after_initialize_patch

Change History

09/18/07 00:47:54 changed by zdennis

  • attachment railties_after_initialize.diff added.

railties after_initialize_patch

09/18/07 00:48:23 changed by zdennis

This patch should be applied from the top level railties directory.

09/18/07 00:49:37 changed by tavon

+1

Tested as best as I could since railties is broken... :)

09/18/07 01:41:13 changed by lotswholetime

+1 Implementation and tests both look good. This would allow multiple plugins and the main application to use this functionality without stepping on each others toes.

09/18/07 01:45:40 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [7507]) Support multiple config.after_initialize blocks so plugins and apps can more easily cooperate. Closes #9582.