Sunday, September 28, 2008

This Router test fails when using named parameters.

I'm trying to create a custom route for my profiles controller located
in plugin. I need to pass the username as a named parameter, but it
doesn't seem to be working for me.

Router::connectNamed(array('username'));
Router::connect('/profiles/:username',
array('plugin'=>'gems','controller'=>'gemsProfiles','action'=>'show'),array('pass'=>array('username')));
$url =
Router::url(array('admin'=>false,'plugin'=>'gems','controller'=>'gemsProfiles','action'=>'show','username'=>'mustan9'));
$this->assertEqual( $url, '/profiles/mustan9' );

This assert fails because $url is "/gems/gemsProfiles/show/
username:mustan9", and as you can see I was expecting "/profiles/
mustan9"

Can anyone see what I've done wrong?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: