为什么我会为不存在的函数收到“缺少路线”错误。
在Reservations
控制器内部,我有add
一个参数的函数:
public function add($carid = null)
{
...
}
匹配路线:
Router::scope('/', function ($routes) {
Router::connect('/rentcar/:id', ['controller' => 'Reservations', 'action' => 'add'],['pass' => ['id'], 'id' => '[0-9]+']);
// rest of the routes not important
...
});
Plugin::routes();
当我访问任何页面时,我看到以下错误:
http://i.stack.imgur.com/ESX5I.jpg
错误消息说:
错误:找不到匹配“数组('controller' => 'Reservations', 'action' => 'add', 'plugin' => NULL, '_ext' => NULL, )”的路由。
...这很奇怪,因为我没有add()
没有参数的函数,相反,我有add($carid)
一个参数的函数。
但是当我添加那条路线时,一切正常:
Router::connect('/rentcar2', ['controller' => 'Reservations', 'action' => 'add']);
到底是怎么回事?