{"action":"closed","issue":{"url":"https://api.github.com/repos/spine/spine/issues/388","labels_url":"https://api.github.com/repos/spine/spine/issues/388/labels{/name}","comments_url":"https://api.github.com/repos/spine/spine/issues/388/comments","events_url":"https://api.github.com/repos/spine/spine/issues/388/events","html_url":"https://github.com/spine/spine/issues/388","id":7999585,"number":388,"title":"When creation of model fails on server, the next save is an update","user":{"login":"omahlama","id":1110213,"avatar_url":"https://avatars.githubusercontent.com/u/1110213?v=3","gravatar_id":"","url":"https://api.github.com/users/omahlama","html_url":"https://github.com/omahlama","followers_url":"https://api.github.com/users/omahlama/followers","following_url":"https://api.github.com/users/omahlama/following{/other_user}","gists_url":"https://api.github.com/users/omahlama/gists{/gist_id}","starred_url":"https://api.github.com/users/omahlama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omahlama/subscriptions","organizations_url":"https://api.github.com/users/omahlama/orgs","repos_url":"https://api.github.com/users/omahlama/repos","events_url":"https://api.github.com/users/omahlama/events{/privacy}","received_events_url":"https://api.github.com/users/omahlama/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2012-10-31T13:42:45Z","updated_at":"2015-05-26T16:25:55Z","closed_at":"2015-05-26T16:25:55Z","body":"Here's my scenario:\r\n* User enters data into \"new item\" form and presses save\r\n* Data gets sent to server\r\n* Server does validation and finds that a field that should be unique is already in use\r\n* Server responds with 422 Unprocessable entity\r\n* Error is shown to user\r\n* User chooses new, unique value for field and presses save\r\n\r\nExpected behavior:\r\nA new post request to \"/items/\"\r\n\r\nActual behavior:\r\nA put request to \"/items/c-473\"\r\n\r\nThe reason is that Model.create sets the id to cid. My workaround is to add a fail parameter to the save function:\r\n\r\nitem.save(fail: () -> \r\n  @id = undefined\r\n)"}}