Routing Concerns

I am not really following up what is happening with the routes concern thing, but I just want to point out that using “def method” like the proposed solution introduces a chance of method conflict:

draw do

def parent_resource

resource :parent

end

resources :posts do

parent_resource

end

end

Bam, now you are conflicting with https://github.com/rails/rails/blob/0dd24728a088fcb4ae616bb5d62734aca5276b1b/actionpack/lib/action_dispatch/routing/mapper.rb#L1414 and it can lead to a considerable amount of hair pulling. I don’t think there is a way for us to detect such conflicts (or is there a way to define a method_added hook in the object singleton class?). Besides, the fact that the current router implementation is a bunch of modules with many private methods (don’t get me started) just makes the chances of conflict higher.

Of the suggestions I have seen so far, I liked the lambda one the most. But then, I am a sucker for functional programming.

Bam, now you are conflicting with https://github.com/rails/rails/blob/0dd24728a088fcb4ae616bb5d62734aca5276b1b/actionpack/lib/action_dispatch/routing/mapper.rb#L1414 and it can lead to a considerable amount of hair pulling. I don’t think there is a way for us to detect such conflicts (or is there a way to define a method_added hook in the object singleton class?). Besides, the fact that the current router implementation is a bunch of modules with many private methods (don’t get me started) just makes the chances of conflict higher.

That’s a reasonable concern.

Of the suggestions I have seen so far, I liked the lambda one the most. But then, I am a sucker for functional programming.

Yeah, the lambda one is nice. My main concern is adding another layer of abstraction/indirection that invites a bloat of routes.

-corey

I’ve explained why concerns are wonderful and not going anywhere on the commit itself:

David,

I've explained why concerns are wonderful and not going anywhere on the
commit itself:
https://github.com/rails/rails/commit/0dd24728a088fcb4ae616bb5d62734aca5276b1b#commitcomment-1749011

Actually you explained that they are not going anywhere. I don't see
an explanation in there about why they are wonderful.

But, since conversation is shut down, I guess we can all sit back and
continue to help teams recover from using your "wonderful" features.

-Corey