Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Shorthand for path method in resources

#70

The path method should take an optional two argument form to allow you to scope a path with a separate resource (for cross-resource path references).

path( :foo ) # the path named foo in the current resource context

path( :foo, :bar ) # the path name foo in the :bar resource context

Optionally, you could do it something like this:

resource( :bar ).path( :foo )

but that is nearly as verbose as using the qualified name and #resource is already defined to return the current resource name.

Reported by dan (at zeraweb) · July 20th, 2008 @ 11:27 PM

State: resolved
Assigned to: dan (at zeraweb) dan (at zeraweb)

Activity

  1. dan (at zeraweb)
    dan (at zeraweb)
    • Milestone set to 0.8.0 - Frozen Donkey Wheel
    • Assigned user changed from Matthew King to dan (at zeraweb)
    • Tag set to mapping, resources

    July 20th, 2008 @ 11:28 PM

  2. dan (at zeraweb)
    dan (at zeraweb)

    Also, if redirect is given a symbol as an argument, I think it should automatically assume that it should call #path; and it should also have the two argument form, so that you can simply do:

    redirect( :foo, :bar )

    which is the same as

    redirect( path( :foo, :bar ) )

    which is the same as

    redirect( path( FooApp::Resources::Bar.path( :foo ) ) )

    July 20th, 2008 @ 11:31 PM

  3. dan (at zeraweb)
    dan (at zeraweb)

    Which makes me wonder if there isn't some sort of pattern here ... esp. when you factor in multi-app scenarios:

    :foo # => the foo mapping in current app and current resource

    %w( bar foo ) # => foo in bar resource in current app

    %w( foo_app bar foo ) # => fully qualified mapping reference

    The only thing is that this is very confusing potentially:

    %w( blog / entry / show )

    could refer to the actual path spec:

    [ :name ]

    or something like that. That is, there are two paths: one logical and one that is the actual URL!

    July 20th, 2008 @ 11:35 PM

  4. Matthew King
    Matthew King

    We don't have a path method defined in Mapping or Resources::Mixin right now. I'm assuming this refers to an instance method on a Resource that we need to define.

    path(:foo) would be equivalent to SomeResource.new.paths.foo

    ??

    July 21st, 2008 @ 07:26 AM

  5. dan (at zeraweb)
    dan (at zeraweb)
    • State changed from new to resolved

    This is implemented as a series of helpers in the response mixin that all follow the same pattern.

    Example

    
      # paths for the "local" app context
      paths( :entry ).show( name )
    
      # paths for an arbitrary app
      paths( :blog, :entry ).show( name )
    
    

    July 27th, 2008 @ 08:36 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.