{"action":"created","issue":{"url":"https://api.github.com/repos/balvig/spyke/issues/58","labels_url":"https://api.github.com/repos/balvig/spyke/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/balvig/spyke/issues/58/comments","events_url":"https://api.github.com/repos/balvig/spyke/issues/58/events","html_url":"https://github.com/balvig/spyke/issues/58","id":103206701,"number":58,"title":"Suggestion: Make difference between has_many and embeds_many","user":{"login":"twentyonetwice","id":255421,"avatar_url":"https://avatars.githubusercontent.com/u/255421?v=3","gravatar_id":"","url":"https://api.github.com/users/twentyonetwice","html_url":"https://github.com/twentyonetwice","followers_url":"https://api.github.com/users/twentyonetwice/followers","following_url":"https://api.github.com/users/twentyonetwice/following{/other_user}","gists_url":"https://api.github.com/users/twentyonetwice/gists{/gist_id}","starred_url":"https://api.github.com/users/twentyonetwice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twentyonetwice/subscriptions","organizations_url":"https://api.github.com/users/twentyonetwice/orgs","repos_url":"https://api.github.com/users/twentyonetwice/repos","events_url":"https://api.github.com/users/twentyonetwice/events{/privacy}","received_events_url":"https://api.github.com/users/twentyonetwice/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-26T08:21:38Z","updated_at":"2015-09-07T14:26:43Z","closed_at":"2015-09-07T14:26:43Z","body":"For example:\r\n\r\n    class Author < Spyke::Base\r\n      ....\r\n      has_many :books, uri: nil\r\n      attributes :name, :age\r\n    end\r\n\r\n    class Book < Spyke::Base\r\n      ....\r\n      attributes :title, :part\r\n    end\r\n\r\nWhen I try to add a book to the author\r\n\r\n    author.books.build(my_attributes)\r\n\r\nSpyke adds an author_id to the embedded book, which is, in embedded documents unnecessary:\r\n\r\nAuthor:\r\n\r\n    {\r\n      \"name\": \"J.R.R. Tolkien\",\r\n      \"age\": 102,\r\n      \"books\": [\r\n        {\r\n          \"title\": \"The Fellowship of the Ring\",\r\n          \"part\": \"Part 1\"\r\n        }, {\r\n          \"title\": \"The Two Towers\",\r\n          \"part\": \"Part 2\"\r\n        }, {\r\n          \"title\": \"The Return of the King\",\r\n          \"part\": \"Part 3\"\r\n        }\r\n      ]\r\n    }\r\n\r\nAs, per intention, all books belongs to this specific author, there's no need to add an author_id to the books within embedded models.\r\n\r\nOr is it possible that I misunderstand your intentions with the has_many associations?\r\n\r\nGreetings\r\nKlaus\r\n"},"comment":{"url":"https://api.github.com/repos/balvig/spyke/issues/comments/138312485","html_url":"https://github.com/balvig/spyke/issues/58#issuecomment-138312485","issue_url":"https://api.github.com/repos/balvig/spyke/issues/58","id":138312485,"user":{"login":"twentyonetwice","id":255421,"avatar_url":"https://avatars.githubusercontent.com/u/255421?v=3","gravatar_id":"","url":"https://api.github.com/users/twentyonetwice","html_url":"https://github.com/twentyonetwice","followers_url":"https://api.github.com/users/twentyonetwice/followers","following_url":"https://api.github.com/users/twentyonetwice/following{/other_user}","gists_url":"https://api.github.com/users/twentyonetwice/gists{/gist_id}","starred_url":"https://api.github.com/users/twentyonetwice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twentyonetwice/subscriptions","organizations_url":"https://api.github.com/users/twentyonetwice/orgs","repos_url":"https://api.github.com/users/twentyonetwice/repos","events_url":"https://api.github.com/users/twentyonetwice/events{/privacy}","received_events_url":"https://api.github.com/users/twentyonetwice/received_events","type":"User","site_admin":false},"created_at":"2015-09-07T14:26:43Z","updated_at":"2015-09-07T14:26:43Z","body":"Sure, it would just be a bit cosmetic, but not necessary ;)"}}