{"id":18627301,"url":"https://github.com/itsnickbarry/shallow-nested-model","last_synced_at":"2025-11-04T01:30:34.431Z","repository":{"id":91490544,"uuid":"58619767","full_name":"ItsNickBarry/shallow-nested-model","owner":"ItsNickBarry","description":"Backbone models to match Rails shallow nested routes","archived":false,"fork":false,"pushed_at":"2016-12-29T20:41:06.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T06:26:41.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ItsNickBarry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-12T07:46:15.000Z","updated_at":"2016-05-12T07:46:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"62658d9d-5409-4860-8811-8e6b13290073","html_url":"https://github.com/ItsNickBarry/shallow-nested-model","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsNickBarry%2Fshallow-nested-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsNickBarry%2Fshallow-nested-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsNickBarry%2Fshallow-nested-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsNickBarry%2Fshallow-nested-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ItsNickBarry","download_url":"https://codeload.github.com/ItsNickBarry/shallow-nested-model/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239425311,"owners_count":19636346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:41:52.587Z","updated_at":"2025-11-04T01:30:34.389Z","avatar_url":"https://github.com/ItsNickBarry.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shallow Nested Model\nUse shallow nested models to allow Backbone to work with Rails shallow nested routes.\n\nA shallow nested model created through a collection will only be posted to its own `url` if the collection's `url` does not exist.  A preexisting model will use its own `url`, which is sufficient to uniquely identify it.\n\n## Example\n\n```ruby\nresources :users, shallow: true do\n  resources :posts\nend\n```\n\n```bash\n$ rake routes\n  user_posts POST   /users/:user_id/posts(.:format) posts#create\n        post GET    /posts/:id(.:format)            posts#show\n             DELETE /posts/:id(.:format)            posts#destroy\n```\n\n```javascript\nPost = Backbone.ShallowNestedModel.extend({\n  urlRoot: '/posts',\n});\n\nUser = Backbone.Model.extend({\n  urlRoot: '/users',\n  initialize: function () {\n    this.posts = new UserPosts(this);\n  },\n});\n\nUserPosts = Backbone.Collection.extend({\n  model: Post,\n  url: '/posts',\n});\n\nvar user = new User();\nvar post = user.posts.create({...});\npost.fetch();\n```\n\nThe new post will be posted to `/users/:user_id/posts`, but will be fetched from `/posts/:id`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsnickbarry%2Fshallow-nested-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsnickbarry%2Fshallow-nested-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsnickbarry%2Fshallow-nested-model/lists"}