{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18672","labels_url":"https://api.github.com/repos/rails/rails/issues/18672/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18672/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18672/events","html_url":"https://github.com/rails/rails/issues/18672","id":55380461,"number":18672,"title":"accepts_nested_attributes_for breaks automatic inverse_of for has_many","user":{"login":"dontfidget","id":1858046,"avatar_url":"https://avatars.githubusercontent.com/u/1858046?v=3","gravatar_id":"","url":"https://api.github.com/users/dontfidget","html_url":"https://github.com/dontfidget","followers_url":"https://api.github.com/users/dontfidget/followers","following_url":"https://api.github.com/users/dontfidget/following{/other_user}","gists_url":"https://api.github.com/users/dontfidget/gists{/gist_id}","starred_url":"https://api.github.com/users/dontfidget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dontfidget/subscriptions","organizations_url":"https://api.github.com/users/dontfidget/orgs","repos_url":"https://api.github.com/users/dontfidget/repos","events_url":"https://api.github.com/users/dontfidget/events{/privacy}","received_events_url":"https://api.github.com/users/dontfidget/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/activerecord","name":"activerecord","color":"0b02e1"}],"state":"open","locked":false,"assignee":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/34","labels_url":"https://api.github.com/repos/rails/rails/milestones/34/labels","id":665192,"number":34,"title":"5.0.0","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":96,"closed_issues":48,"state":"open","created_at":"2014-05-21T00:58:22Z","updated_at":"2015-01-28T17:10:52Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-01-24T18:41:46Z","updated_at":"2015-01-28T19:00:19Z","closed_at":null,"body":"Adding accepts_nested_attributes_for seems to break the automatic setting of inverse_of.  I have a self-contained gist for this at https://gist.github.com/dontfidget/c336923ee94609528095.\r\n\r\n```\r\n\r\nclass Post < ActiveRecord::Base\r\n  has_many :comments\r\n  accepts_nested_attributes_for :comments # removing this line makes the test pass\r\nend\r\n \r\nclass Comment < ActiveRecord::Base\r\n  belongs_to :post\r\nend\r\n \r\nclass BugTest < Minitest::Test\r\n  def test_inverse_of\r\n    post = Post.new\r\n    post.comments << Comment.new\r\n \r\n    assert_equal post.comments.first.post, post\r\n  end\r\nend\r\n```\r\n\r\nRemoving `accepts_nested_attributes_for` will make it pass.  Also, adding explicit inverse_of will make it pass.  Using create instead of new will also make it pass.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/71893745","html_url":"https://github.com/rails/rails/issues/18672#issuecomment-71893745","issue_url":"https://api.github.com/repos/rails/rails/issues/18672","id":71893745,"user":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T19:00:19Z","updated_at":"2015-01-28T19:00:19Z","body":"@aalvarado The issue is automatic inverse of, not when manually set."}}