Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Namespace Conflict: Journey is a very generic name #49

Closed
samlown opened this Issue · 25 comments

11 participants

Sam Lown Luca Liberati Aaron Patterson Andrew White George Guimarães Rafael Mendonça França Len Jaffe Donald Ball Xavier Noria Jeremy Kemper Daniel Wiesmann
Sam Lown

Hi. Sorry for arriving a bit late here, but we only just got round to starting an upgrade to Rails 3.2.

Unfortunately, we have a model in our project called "Journey". This causes a conflict with this new Journey module in Rails 3.2.

Firstly, is there a known way to get around this issue? (I can't think of any, but you never know.)

Secondly, could you consider renaming the project to something that isn't a common noun? Even a made-up verbal noun would be better than "journey", like "journeying", "journeyer", "travelling", or "actionjourney". Who cares to be honest, as far as I can tell no one is every actually going to type it in except the few programmers maintaining ActionPack and the project itself.

I really hope this can be resolved, in the meantime we're rolling back to Rails 3.1.

Luca Liberati

Why don't you use a namespace? So you can use Journey for your model and from the gem

Sam Lown

A namespace would work, but its a serious amount of effort to rename everything. Its been my experience that namespacing models in Rails is generally more effort than its worth.

The solution I have in mind at the moment, if I can't convince anyone to rename, is to write a couple of Rake tasks to automatically rename Journey in journey and ActionPack branches. When a new release comes out, merge from release tag and re-run rake. Seriously lame, but quite considerably easier than renaming our project.

Aaron Patterson
Owner
Luca Liberati

that's the point, I'm with @tenderlove. If you have name conflict with external gems, you should take action, not the other way around.

Simply take the effort to namespace your model if it's so important to call it Journey.
I don't get why it's less effort to write a rake task to mess with Journey router code, rather than write a bunch of YourNamespace::Journey and forget about it.

Andrew White
Owner

Its been my experience that namespacing models in Rails is generally more effort than its worth.

This may have been true in the past but I regularly use namespaced models (both nested models and models inside a module) without any problems.

As for renaming your model why not use Trip? There doesn't seem to be any collision issues with a gem for that one.

Sam Lown

What makes your private project (that I would have no idea about) more important than mine?

Absolutely nothing :-)

My only line of reasoning is that "Journey" is a very generic common noun, which many other developers are likely to use now and in the future. It is my newly formed belief (frankly, I never thought about this before) that projects should not be named after common nouns as these are the names more likely to be used by data modellers to describe things in the physical world.

I guess this doesn't come up very often because there are very few projects that use common nouns. Rack is about the only gem required by Rails in a similar situation.

Journeys are our business, it is the core of everything we do. Renaming would be totally impractical. We don't just use it in Rails, we use it in our Node.js server, Android app, and iOS (Obj-C, Rubymotion [1]) apps, with more in the pipeline. Whereas Journey is mentioned 15 times in ActionPack. IMHO it is far easier for us in the long term (given how often we upgrade rails) to create a quick rake task to search and replace.

I really hope you understand my predicament.

[1] http://blog.rubymotion.com/post/30514580062/rubymotion-success-story-cabify

Aaron Patterson
Owner

Remaning the gem is also very impractical. It means breaking anyone that relies on the current constants. Breaking current constants means that I must release a major version. We don't want to switch Rails's dependencies to a major version in a bugfix release.

I understand your predicament, but can you see mine? It impacts many people and if I want to follow semver (which I do), it takes much more time than doing a quick release.

Journeys are our business, it is the core of everything we do. Renaming would be totally impractical.

I'm open to helping, but this kind of logic doesn't sway me. "Journeys" being the core of your business doesn't make changing code impractical. Can you offer a solution besides "please rename your gem"? TBH, I'm partial to pushing the router back in to Rails, but that certainly won't happen for Rails 4 (or a bug release version).

George Guimarães

This spurs a interesting discussion (at least for me): as gems creators (and maintainers), what are the precautions one has to think of when naming a global constant?

Is there any discussion on this already opened in mailing lists or github?

Sam Lown

I totally appreciate that it would not be possible without a major release, I certainly wouldn't hope for a modification to the current Rails 3.2, way too late for that.

It would be great if this could be considered for Rails 4 though, or at least have a new name before then so I can run my own patched version of Rails 3.2.

A quick google search [1] suggests that 'journey' is only used by ActionPack, nothing else. This is pure speculation, but I don't see much evidence to believe many people would actually notice if the name was changed.

I really don't have anything else to go on here in terms of solutions. I can only try to appeal to your nice natures and suggest that common nouns should not be used for the names of projects. I'd certainly be willing to offer a couple of pull requests with a new name if that helps...

[1] site:gemcutter.org dependencies journey -replacement

Rafael Mendonça França

In one of my projects I check for the Journey constant. It is not a open source project but renaming it would make me to change my code.

Len Jaffe
Donald Ball

If the suggested intervention is for @samlown to namespace his models, might it then make sense for Rails 4 to start generating application models and other classes in the application namespace by default?

Aaron Patterson
Owner

It would be great if this could be considered for Rails 4 though, or at least have a new name before then so I can run my own patched version of Rails 3.2.

I think we have time for Rails 4 to rename (though if someone made the patches for me, I would appreciate it).

Might I suggest ActionRouter or ActiveRouter.

I'm fine with either of these.

@rafaelfranca what are you trying to detect by looking for the constant? Maybe there is something we need to do better?

Xavier Noria
Owner

Editorial note for whoever does the patch :). To be coherent with the naming conventions in Rails ActionRouter would be the name of the Ruby module. And "Action Router" the name of the component itself.

Andrew White
Owner

Wouldn't it make more sense to move it to the ActionDispatch namespace (as ActionDispatch::Router I guess) - after all that's where most of the code that interfaces with it is and we may be able to streamline some things once it's in there.

Andrew White
Owner

Actually looking at it ActionDispatch::Routing::Router makes the most sense - the only real thing that would be a bit of a mess is Journey::Routes and ActionDispatch::RouteSet, as the latter is essentially a wrapper around the former so we'd probably want to merge those two in some way.

Aaron Patterson
Owner

@pixeltrix you may be right, but I think that would mean shipping the existing Journey code along with the AP gem. Renaming the gem may be a less extreme change.

That said, I'm not against pushing the code in to AD. The main reason is that I think the routing code was prematurely extracted from Rails. I like the idea of having a separate gem that knows how to route, but the interface is so complex (and specific) that basically only Rails can use it. I'd like to extract a better object model for the router.

Opinions are definitely welcome!

Rafael Mendonça França

@tenderlove I searched in the code and I'm not checking the constant anymore.

I think is a good path renaming the Journey to Action Router.

Jeremy Kemper
Owner

Your constant name is already in use. You may want to try

  • Journey0001
  • Journey1973
  • Jurrney
  • FrumiousBandersnatch

:heart: ruby

Andrew White
Owner

@pixeltrix you may be right, but I think that would mean shipping the existing Journey code along with the AP gem. Renaming the gem may be a less extreme change.

Whether it's in a separate gem or in the AP gem gem it's still the same weight of code - it's not like anyone would use AP with something other than Journey - one less dependency for Bundler to resolve.

That said, I'm not against pushing the code in to AD. The main reason is that I think the routing code was prematurely extracted from Rails. I like the idea of having a separate gem that knows how to route, but the interface is so complex (and specific) that basically only Rails can use it. I'd like to extract a better object model for the router.

Agree on the premature extraction - perhaps re-integrate for now and look to a general purpose router for Rack 2 (whatever the status of that is).

Daniel Wiesmann

I've got the same problem: Rails 3.2 upgrade from 2.3.x, and a model named Journey.
Took me a fair bit of time to figure out that this was the problem, actually.

@samlown, did you end up namespacing Journey, or write those rake tasks?

Sam Lown

@bakongo we've been too busy and not really had a need to upgrade from 3.1 yet. I'll post a gist when we have something.

Len Jaffe

Not for nothing, this is a problem with flat namespaces.

Andrew White pixeltrix referenced this issue from a commit in rails/rails
Andrew White pixeltrix Integrate Journey into Action Dispatch
Move the Journey code underneath the ActionDispatch namespace so
that we don't pollute the global namespace with names that may
be used for models.

Fixes rails/journey#49.
81bcfba
Andrew White pixeltrix referenced this issue from a commit in rails/rails
Andrew White pixeltrix Integrate Journey into Action Dispatch
Move the Journey code underneath the ActionDispatch namespace so
that we don't pollute the global namespace with names that may
be used for models.

Fixes rails/journey#49.
56fee39
Andrew White
Owner

Closing this since Journey has now been integrated into Action Dispatch.

Andrew White pixeltrix closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.