Re: Routing Concerns

216 views
Skip to first unread message

José Valim

unread,
Aug 22, 2012, 8:04:17 AM8/22/12
to rubyonra...@googlegroups.com
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.


On Tuesday, August 21, 2012 11:09:05 PM UTC-3, Corey Haines wrote:
So, there's been some commenting on the Routing Concerns that has been added to rails.
https://github.com/rails/rails/commit/0dd24728a088fcb4ae616bb5d62734aca5276b1b

This seems to be adding no more functionality or ease of use than simply using methods, Ruby's standard form of reuse.

Here's are links to comments about using methods:

I don't see any added value that this adds. Would love to invite other comments and discussion on what this feature adds over just using Ruby.

Corey Haines

unread,
Aug 22, 2012, 8:34:34 AM8/22/12
to rubyonra...@googlegroups.com
On Wednesday, August 22, 2012 7:04:17 AM UTC-5, José Valim wrote:
...
 
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

DHH

unread,
Aug 22, 2012, 9:12:20 AM8/22/12
to rubyonra...@googlegroups.com
I've explained why concerns are wonderful and not going anywhere on the commit itself:

Corey Haines

unread,
Aug 22, 2012, 9:16:07 AM8/22/12
to rubyonra...@googlegroups.com
David,

On Wed, Aug 22, 2012 at 8:12 AM, DHH <da...@loudthinking.com> wrote:
> 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
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-core/-/guF9Z-da6vIJ.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-co...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
Reply all
Reply to author
Forward
0 new messages