{"action":"created","issue":{"url":"https://api.github.com/repos/tunecino/yii2-nested-rest/issues/2","repository_url":"https://api.github.com/repos/tunecino/yii2-nested-rest","labels_url":"https://api.github.com/repos/tunecino/yii2-nested-rest/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/tunecino/yii2-nested-rest/issues/2/comments","events_url":"https://api.github.com/repos/tunecino/yii2-nested-rest/issues/2/events","html_url":"https://github.com/tunecino/yii2-nested-rest/issues/2","id":148354762,"number":2,"title":"Trying to get it to work","user":{"login":"dbd5","id":9496750,"avatar_url":"https://avatars.githubusercontent.com/u/9496750?v=3","gravatar_id":"","url":"https://api.github.com/users/dbd5","html_url":"https://github.com/dbd5","followers_url":"https://api.github.com/users/dbd5/followers","following_url":"https://api.github.com/users/dbd5/following{/other_user}","gists_url":"https://api.github.com/users/dbd5/gists{/gist_id}","starred_url":"https://api.github.com/users/dbd5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbd5/subscriptions","organizations_url":"https://api.github.com/users/dbd5/orgs","repos_url":"https://api.github.com/users/dbd5/repos","events_url":"https://api.github.com/users/dbd5/events{/privacy}","received_events_url":"https://api.github.com/users/dbd5/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tunecino/yii2-nested-rest/labels/status:need%20more%20info","name":"status:need more info","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-14T13:02:05Z","updated_at":"2016-04-14T19:39:22Z","closed_at":null,"body":"I've done the following;\r\n\r\n1. Installed as instructed with composer.\r\n2. Placed **public function actions(){...}** verbatim inside my ApiController because all controllers inherit from it.\r\n3. Added a section to my urlManager rules array (reproduced below)\r\n\r\nI expect GET http://localhost/api/web/v1/testpapers/133/testquestions to fetch the list of questions in testpaper 133 and http://localhost/api/web/v1/testpapers/133/testquestions/id to fetch a particular question in testpaper 133, but I get {\"name\":\"Not Found\",\"message\":\"Page not found.\",\"code\":0,\"status\":404,\"type\":\"yii\\\\web\\\\NotFoundHttpException\"}\r\n\r\nThere is of course an existing 1 to many relationship between testpaper and testquestions. \r\nCould you take a look and advise what I could be missing. Perhaps this will be an actual example that will help others configure their setup correctly if we can get it to work.\r\n\r\nAll GET requests work except the nested related requests\r\n\r\nRegards,\r\n\r\nAdam\r\n____\r\n\r\n            'rules' => [\r\n                // Based on Yii defaults UrlRule class\r\n                [\r\n                    'class' => 'yii\\rest\\UrlRule',\r\n                    'controller' => [\r\n                        'v1/apiuser',\r\n                        'v1/question',\r\n                        'v1/testconfig',\r\n                        'v1/testpaper',\r\n                        'v1/testquestions',\r\n                    ],\r\n                    'tokens' => [\r\n                        '{id}' => '<id:\\\\w+>'\r\n                    ],\r\n                ],\r\n\r\n                // Based on tunecino's collection of helper actions and a custom UrlRule class\r\n                // https://github.com/tunecino/yii2-nested-rest\r\n                [\r\n                    // the custom UrlRule (required)\r\n                    'class' => 'tunecino\\nestedrest\\UrlRule',\r\n\r\n                    // the model class name (required)\r\n                    'modelClass' => 'api\\common\\models\\Testpaper',\r\n\r\n                    // relations names to be nested with this model they should be already\r\n                    // defined in the model class. (required)\r\n                    'relations' => ['user','testquestions'],\r\n\r\n                    // used to generate the 'prefix'. default: the model name pluralized (optional)\r\n                    // 'resourceName' => 'players',\r\n                    'resourceName' => 'testquestions',\r\n\r\n                    // building related rules using 'controller => ['teams' => 'v1/team']'\r\n                    // instead of 'controller => ['team']' (optional)\r\n                    'modulePrefix' => 'v1',\r\n\r\n                    // the default list of patterns. they may all be overridden here or just edited\r\n                    // within $only, $except and $extraPatterns properties (optional)\r\n                    'patterns' => [\r\n                        'GET,HEAD {IDs}' => 'nested-view',\r\n                        'GET,HEAD' => 'nested-index',\r\n                        'POST' => 'nested-create',\r\n                        'PUT {IDs}' => 'nested-link',\r\n                        'DELETE {IDs}' => 'nested-unlink',\r\n                        'DELETE' => 'nested-unlink-all',\r\n                        '{id}' => 'options',\r\n                        '' => 'options',\r\n                    ],\r\n\r\n                ],\r\n            ],\r\n"},"comment":{"url":"https://api.github.com/repos/tunecino/yii2-nested-rest/issues/comments/210115674","html_url":"https://github.com/tunecino/yii2-nested-rest/issues/2#issuecomment-210115674","issue_url":"https://api.github.com/repos/tunecino/yii2-nested-rest/issues/2","id":210115674,"user":{"login":"tunecino","id":5133397,"avatar_url":"https://avatars.githubusercontent.com/u/5133397?v=3","gravatar_id":"","url":"https://api.github.com/users/tunecino","html_url":"https://github.com/tunecino","followers_url":"https://api.github.com/users/tunecino/followers","following_url":"https://api.github.com/users/tunecino/following{/other_user}","gists_url":"https://api.github.com/users/tunecino/gists{/gist_id}","starred_url":"https://api.github.com/users/tunecino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tunecino/subscriptions","organizations_url":"https://api.github.com/users/tunecino/orgs","repos_url":"https://api.github.com/users/tunecino/repos","events_url":"https://api.github.com/users/tunecino/events{/privacy}","received_events_url":"https://api.github.com/users/tunecino/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T19:39:22Z","updated_at":"2016-04-14T19:39:22Z","body":"@dbd5 model looks good. according to your configurations this is the yii/rest/UrlRule object that should be generated by this extension:\r\n```\r\nArray\r\n(\r\n    [class] => yii\\rest\\UrlRule\r\n    [patterns] => Array\r\n        (\r\n            [GET,HEAD {IDs}] => nested-view\r\n            [GET,HEAD] => nested-index\r\n            [POST] => nested-create\r\n            [PUT {IDs}] => nested-link\r\n            [DELETE {IDs}] => nested-unlink\r\n            [DELETE] => nested-unlink-all\r\n            [{id}] => options\r\n            [] => options\r\n        )\r\n\r\n    [prefix] => testquestions/<testpaper_id:\\d+>\r\n    [controller] => Array\r\n        (\r\n            [testquestions] => v1/testquestion\r\n        )\r\n)\r\n```\r\nSo there is already an error with with the `resourceName`. it should be `'resourceName' => 'testpapers'` instead of `'resourceName' => 'testquestions'`. can you set it to `testquestions` ? (or just comment that line as by default it will be set to the model name pluralized any way) then tell me please if it works."}}