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

Ticket #11000 (closed defect: fixed)

Opened 8 months ago

Last modified 7 months ago

[PATCH] Teach script/generate to heed plugin_paths

Reported by: glv Assigned to: core
Priority: normal Milestone: 2.x
Component: Railties Version: edge
Severity: normal Keywords: plugin generator loading patch configuration verified
Cc:

Description

script/generate is documented to find generators in plugins, but it ignores configuration.plugin_paths, and so will only find generators in plugins that are in vendor/plugins. This patch fixes that.

Notes and possible points of discussion:

1. The generate script loads environment.rb, and later looks for generators; by the time the generator search is performed, the initializer and configuration objects are long gone. Either the generation framework has to hook in and be called to perform the search during the initialization process, or the configuration object has to be saved somehow. I opted for a module attribute Rails.configuration.

2. During typical Rails startup, Rails::Initializer.run is called at least twice, with different 'command' parameters. Rails.configuration is set at the end of the process method, so that it will only be set with the Configuration instance that was used to actually configure the environment.

3. This patch slightly changes the way plugin-based generators are reported in the script/generate usage message.

Attachments

generator_plugin_paths (5.8 kB) - added by glv on 02/09/08 15:36:50.
generator_plugin_paths.diff (5.8 kB) - added by glv on 02/11/08 17:47:00.

Change History

02/09/08 15:36:50 changed by glv

  • attachment generator_plugin_paths added.

02/09/08 15:37:57 changed by glv

Updated patch to improve tests and avoid conflict introduced with [8806].

02/09/08 16:25:34 changed by glv

Re-attached patch file with '.diff' suffix

02/11/08 17:02:43 changed by rsanheim

+1, more consistency in plugins, regardless of how they are installed.

02/11/08 17:47:00 changed by glv

  • attachment generator_plugin_paths.diff added.

02/11/08 17:50:33 changed by glv

Updated patch: moved setting of Rails.configuration to the top of Initializer#process. This gives (to mention just one example) application initializers access to the configuration object, without the "eval with binding" gyrations required when loading plugins/*/init.rb.

02/15/08 14:25:14 changed by stuthulhu

+1, would use this immediately

02/15/08 14:41:18 changed by abedra

+1

03/01/08 14:35:22 changed by glv

  • keywords changed from plugin generator loading patch configuration to plugin generator loading patch configuration verified.

03/13/08 02:47:30 changed by david

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

(In [9017]) Fixed that script/generate would not look for plugin generators in plugin_paths (closes #11000) [glv]