Shorthand for path method in resources
Reported by dan (at zeraweb) | July 20th, 2008 @ 11:27 PM | in 0.8.0 - Frozen Donkey Wheel
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.
Comments and changes to this ticket
-

dan (at zeraweb) July 20th, 2008 @ 11:28 PM
- → Tag changed from to mapping resources
- → Milestone changed from to 0.8.0 - Frozen Donkey Wheel
- → Assigned user changed from Matthew King to dan (at zeraweb)
-

dan (at zeraweb) July 20th, 2008 @ 11:31 PM
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 ) ) )
-

dan (at zeraweb) July 20th, 2008 @ 11:35 PM
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!
-
Matthew King July 21st, 2008 @ 07:26 AM
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
??
-

dan (at zeraweb) July 27th, 2008 @ 08:36 PM
- → 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 )
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Resource-oriented Web apps.
