Idiomatic use for exists? predicate

52 views
Skip to first unread message

Hussein B.

unread,
Aug 20, 2015, 8:14:00 AM8/20/15
to Liberator
Hi,

For a request such as:

/tree/:tree-id/leafs/:leaf-id

:exists? should check for tree-id, leaf-id or both?

Thanks for help.


Philipp Meier

unread,
Aug 20, 2015, 9:22:52 AM8/20/15
to Liberator
Hi,


Am Donnerstag, 20. August 2015 14:14:00 UTC+2 schrieb Hussein B.:

For a request such as:

/tree/:tree-id/leafs/:leaf-id

:exists? should check for tree-id, leaf-id or both? 

You should check for both, I guess. However if the leaf-id alone gives your enough information you might only check for that. The URL would not make too much sense in this case and I'd mount the resource to /leafs/:leaf-id instead. If you validate the tree-id as a kind of authorization you might want to use the :authorized? decision to check whether the leaf-id matches the tree-id.

-billy.

Hussein B.

unread,
Aug 20, 2015, 10:04:50 AM8/20/15
to Liberator
Clear. Thanks for your help.
Reply all
Reply to author
Forward
0 new messages