{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/3502","labels_url":"https://api.github.com/repos/emberjs/data/issues/3502/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/3502/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/3502/events","html_url":"https://github.com/emberjs/data/issues/3502","id":93355565,"number":3502,"title":"Cannot add duplicate models to a hasMany relationship","user":{"login":"jdreux","id":505955,"avatar_url":"https://avatars.githubusercontent.com/u/505955?v=3","gravatar_id":"","url":"https://api.github.com/users/jdreux","html_url":"https://github.com/jdreux","followers_url":"https://api.github.com/users/jdreux/followers","following_url":"https://api.github.com/users/jdreux/following{/other_user}","gists_url":"https://api.github.com/users/jdreux/gists{/gist_id}","starred_url":"https://api.github.com/users/jdreux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdreux/subscriptions","organizations_url":"https://api.github.com/users/jdreux/orgs","repos_url":"https://api.github.com/users/jdreux/repos","events_url":"https://api.github.com/users/jdreux/events{/privacy}","received_events_url":"https://api.github.com/users/jdreux/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-06T19:16:03Z","updated_at":"2015-07-07T22:16:12Z","closed_at":"2015-07-07T22:16:12Z","body":"Adding the same model more than once to a relationship property doesn't do anything: \r\n\r\n    #order/model.coffee\r\n    Order = DS.Model.extend {\r\n      line_items: DS.hasMany 'product', {async: true}\r\n    }\r\n\r\n\r\n\r\n    #product/route.coffee\r\n    ...\r\n    actions:\r\n        # Not actually my code but illustrates the problem\r\n        addToCart: (product1, product2)->\r\n          order = @modelFor 'order'\r\n          console.log order.get('line_items.length') # prints 0\r\n\r\n          order.get('line_items').pushObject product1\r\n          console.log order.get('line_items.length') # prints 1\r\n\r\n          order.get('line_items').pushObject product2\r\n          console.log order.get('line_items.length') # prints 2\r\n\r\n          order.get('line_items').pushObject product1\r\n          console.log order.get('line_items.length') # prints 2\r\n\r\n          order.get('line_items').pushObject product2\r\n          console.log order.get('line_items.length') # prints 2\r\n          ...\r\n\r\n\r\n\r\nRelated SO question: http://stackoverflow.com/questions/31150242/ember-data-does-not-allow-duplicate-entries-in-hasmany-relationships/31218890#31218890"},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/119359622","html_url":"https://github.com/emberjs/data/issues/3502#issuecomment-119359622","issue_url":"https://api.github.com/repos/emberjs/data/issues/3502","id":119359622,"user":{"login":"wecc","id":708205,"avatar_url":"https://avatars.githubusercontent.com/u/708205?v=3","gravatar_id":"","url":"https://api.github.com/users/wecc","html_url":"https://github.com/wecc","followers_url":"https://api.github.com/users/wecc/followers","following_url":"https://api.github.com/users/wecc/following{/other_user}","gists_url":"https://api.github.com/users/wecc/gists{/gist_id}","starred_url":"https://api.github.com/users/wecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wecc/subscriptions","organizations_url":"https://api.github.com/users/wecc/orgs","repos_url":"https://api.github.com/users/wecc/repos","events_url":"https://api.github.com/users/wecc/events{/privacy}","received_events_url":"https://api.github.com/users/wecc/received_events","type":"User","site_admin":false},"created_at":"2015-07-07T22:16:12Z","updated_at":"2015-07-07T22:16:12Z","body":"I'm closing as this is not a bug."}}