This project is archived and is in readonly mode.
find railties by name
Reported by Josh Susser | March 25th, 2010 @ 06:18 AM | in 3.0.2
Very simple 1-liner method to find railties and engines by name.
module Rotary
class Wankle < Rails::Engine
engine_name :wankle
end
end
Rails::Engine.named(:wankle) # => Rotary::Wankle
Comments and changes to this ticket
-
Josh Susser March 25th, 2010 @ 06:23 AM
- Tag changed from railties to patch, railties
-
Josh Susser March 25th, 2010 @ 06:35 AM
- no changes were found...
-
José Valim March 26th, 2010 @ 12:08 AM
- 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 March 26th, 2010 @ 04:31 AM
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 March 26th, 2010 @ 08:21 AM
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 March 26th, 2010 @ 02:58 PM
- 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 March 26th, 2010 @ 03:41 PM
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 March 26th, 2010 @ 04:35 PM
The default naming will be removed soon, too :)
It's only there to provide a
config.defaultname
which 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) March 26th, 2010 @ 06:28 PM
@jeremy what's the problem with this for cases only where a name is provided?
-
José Valim March 26th, 2010 @ 06:32 PM
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 March 26th, 2010 @ 06:34 PM
I just reverted the commit and removed the naming in favor of "config.railtie_name = {}".
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>