This project is archived and is in readonly mode.
find railties by name
-
Josh Susser
- Tag changed from railties to patch, railties
-
José Valim
- Milestone cleared.
- State changed from new to open
- Assigned user changed from Yehuda Katz (wycats) to José Valim
Could you provide an use case please?
-
Josh Susser
I need this for my patch to run migrations within engines, to allow identifying an engine by name. Seemed to make sense to make it a separate patch.
-
José Valim
Good reason and excellent idea to make a separate patch. I really just wanted to understand the use case (and yours is good). I will apply it soon. :)
-
Jeremy Kemper
- State changed from open to committed
http://github.com/rails/rails/commit/7b8399b80cfff58cfe2313187ca3c8...
I'm not a fan of this. Names were optional before, only used for config.pluginname.* and I'd rather keep it that way. Use the class name for lookup.
-
Josh Susser
Jeremy, what's the downside? Names are still optional when creating railties/engines - if you don't specify one the railtie gets assigned the default name based on its class name. But allowing use of a developer-assigned name means you can drop in a replacement class that follows the same API. Example: engine Basic::UserAuthSystem is named :user_auth. I like SuperFantastic::UserAuthentication. If other engines only refer to it using the symbolic name, you don't have to do FactoryFactory tricks in your code to use an alternate implementation.
-
Jeremy Kemper
The default naming will be removed soon, too :)
It's only there to provide a
config.defaultnamewhich most plugins don't use.I like the drop-in replacement idea, but I think that's more likely to cause collisions than intentional drop-in. There's probably a better API for this.
-
Yehuda Katz (wycats)
@jeremy what's the problem with this for cases only where a name is provided?
-
José Valim
The main problem by adding a method that searches by name, is that people will think they are required to give a name.
If the case is about migrations, I guess we could have a configuration where a railtie could explicitly say the name to be used in migrations or do something like Jeremy suggested.
-
José Valim
I just reverted the commit and removed the naming in favor of "config.railtie_name = {}".
