{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/27937485","id":27937485,"diff_hunk":"@@ -323,14 +324,21 @@ def validate_collection_association(reflection)\n       # Returns whether or not the association is valid and applies any errors to\n       # the parent, <tt>self</tt>, if it wasn't. Skips any <tt>:autosave</tt>\n       # enabled records if they're marked_for_destruction? or destroyed.\n-      def association_valid?(reflection, record)\n+      def association_valid?(reflection, record, index=nil)\n         return true if record.destroyed? || record.marked_for_destruction?\n \n         validation_context = self.validation_context unless [:create, :update].include?(self.validation_context)\n         unless valid = record.valid?(validation_context)\n           if reflection.options[:autosave]\n             record.errors.each do |attribute, message|\n-              attribute = \"#{reflection.name}.#{attribute}\"\n+              options = self.nested_attributes_options[reflection.name] \n+              if ActiveRecord::Base.index_nested_attribute_errors \n+                attribute = \"#{reflection.name}[#{index}].#{attribute}\"\n+              elsif index.nil? or options.nil? or not options[:index_errors]\n+                attribute = \"#{reflection.name}.#{attribute}\"\n+              else\n+                attribute = \"#{reflection.name}[#{index}].#{attribute}\"","path":"activerecord/lib/active_record/autosave_association.rb","position":36,"original_position":36,"commit_id":"1976af5ac782a85e1afc6fc7d069bbc8ed60226b","original_commit_id":"1976af5ac782a85e1afc6fc7d069bbc8ed60226b","user":{"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},"body":"This branch is the same as the first, so I think we can improve this conditionals to have only two branches.","created_at":"2015-04-08T01:56:04Z","updated_at":"2015-04-08T01:56:04Z","html_url":"https://github.com/rails/rails/pull/19686#discussion_r27937485","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/19686","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/27937485"},"html":{"href":"https://github.com/rails/rails/pull/19686#discussion_r27937485"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/19686"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/19686","id":32771040,"html_url":"https://github.com/rails/rails/pull/19686","diff_url":"https://github.com/rails/rails/pull/19686.diff","patch_url":"https://github.com/rails/rails/pull/19686.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/19686","number":19686,"state":"open","locked":false,"title":"Errors can be indexed with nested attributes","user":{"login":"mprobber","id":2939688,"avatar_url":"https://avatars.githubusercontent.com/u/2939688?v=3","gravatar_id":"","url":"https://api.github.com/users/mprobber","html_url":"https://github.com/mprobber","followers_url":"https://api.github.com/users/mprobber/followers","following_url":"https://api.github.com/users/mprobber/following{/other_user}","gists_url":"https://api.github.com/users/mprobber/gists{/gist_id}","starred_url":"https://api.github.com/users/mprobber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mprobber/subscriptions","organizations_url":"https://api.github.com/users/mprobber/orgs","repos_url":"https://api.github.com/users/mprobber/repos","events_url":"https://api.github.com/users/mprobber/events{/privacy}","received_events_url":"https://api.github.com/users/mprobber/received_events","type":"User","site_admin":false},"body":"accepts_nested_attributes_for can now take index_errors: true as an\r\noption.  When this is enabled, errors for nested models will be\r\nreturned alongside an index, as opposed to just the nested model name.\r\nThis option can also be enabled globally in a configuration file.\r\n\r\n@tsun1215\r\nrails/rails#8638","created_at":"2015-04-07T14:49:01Z","updated_at":"2015-04-08T01:56:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/19686/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/19686/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/19686/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/1976af5ac782a85e1afc6fc7d069bbc8ed60226b","head":{"label":"tsun1215:index_errors","ref":"index_errors","sha":"1976af5ac782a85e1afc6fc7d069bbc8ed60226b","user":{"login":"tsun1215","id":2829302,"avatar_url":"https://avatars.githubusercontent.com/u/2829302?v=3","gravatar_id":"","url":"https://api.github.com/users/tsun1215","html_url":"https://github.com/tsun1215","followers_url":"https://api.github.com/users/tsun1215/followers","following_url":"https://api.github.com/users/tsun1215/following{/other_user}","gists_url":"https://api.github.com/users/tsun1215/gists{/gist_id}","starred_url":"https://api.github.com/users/tsun1215/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsun1215/subscriptions","organizations_url":"https://api.github.com/users/tsun1215/orgs","repos_url":"https://api.github.com/users/tsun1215/repos","events_url":"https://api.github.com/users/tsun1215/events{/privacy}","received_events_url":"https://api.github.com/users/tsun1215/received_events","type":"User","site_admin":false},"repo":{"id":30122523,"name":"rails","full_name":"tsun1215/rails","owner":{"login":"tsun1215","id":2829302,"avatar_url":"https://avatars.githubusercontent.com/u/2829302?v=3","gravatar_id":"","url":"https://api.github.com/users/tsun1215","html_url":"https://github.com/tsun1215","followers_url":"https://api.github.com/users/tsun1215/followers","following_url":"https://api.github.com/users/tsun1215/following{/other_user}","gists_url":"https://api.github.com/users/tsun1215/gists{/gist_id}","starred_url":"https://api.github.com/users/tsun1215/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsun1215/subscriptions","organizations_url":"https://api.github.com/users/tsun1215/orgs","repos_url":"https://api.github.com/users/tsun1215/repos","events_url":"https://api.github.com/users/tsun1215/events{/privacy}","received_events_url":"https://api.github.com/users/tsun1215/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tsun1215/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/tsun1215/rails","forks_url":"https://api.github.com/repos/tsun1215/rails/forks","keys_url":"https://api.github.com/repos/tsun1215/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tsun1215/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tsun1215/rails/teams","hooks_url":"https://api.github.com/repos/tsun1215/rails/hooks","issue_events_url":"https://api.github.com/repos/tsun1215/rails/issues/events{/number}","events_url":"https://api.github.com/repos/tsun1215/rails/events","assignees_url":"https://api.github.com/repos/tsun1215/rails/assignees{/user}","branches_url":"https://api.github.com/repos/tsun1215/rails/branches{/branch}","tags_url":"https://api.github.com/repos/tsun1215/rails/tags","blobs_url":"https://api.github.com/repos/tsun1215/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tsun1215/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tsun1215/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/tsun1215/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tsun1215/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/tsun1215/rails/languages","stargazers_url":"https://api.github.com/repos/tsun1215/rails/stargazers","contributors_url":"https://api.github.com/repos/tsun1215/rails/contributors","subscribers_url":"https://api.github.com/repos/tsun1215/rails/subscribers","subscription_url":"https://api.github.com/repos/tsun1215/rails/subscription","commits_url":"https://api.github.com/repos/tsun1215/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/tsun1215/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/tsun1215/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/tsun1215/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/tsun1215/rails/contents/{+path}","compare_url":"https://api.github.com/repos/tsun1215/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tsun1215/rails/merges","archive_url":"https://api.github.com/repos/tsun1215/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tsun1215/rails/downloads","issues_url":"https://api.github.com/repos/tsun1215/rails/issues{/number}","pulls_url":"https://api.github.com/repos/tsun1215/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/tsun1215/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/tsun1215/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tsun1215/rails/labels{/name}","releases_url":"https://api.github.com/repos/tsun1215/rails/releases{/id}","created_at":"2015-01-31T18:58:09Z","updated_at":"2015-02-28T19:15:34Z","pushed_at":"2015-04-07T18:39:19Z","git_url":"git://github.com/tsun1215/rails.git","ssh_url":"git@github.com:tsun1215/rails.git","clone_url":"https://github.com/tsun1215/rails.git","svn_url":"https://github.com/tsun1215/rails","homepage":"http://rubyonrails.org","size":129659,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"bd51bbc02842ac59b53fa7851a7da3612a474119","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-04-07T22:19:10Z","pushed_at":"2015-04-07T22:48:32Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":401469,"stargazers_count":25595,"watchers_count":25595,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10077,"mirror_url":null,"open_issues_count":746,"forks":10077,"open_issues":746,"watchers":25595,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/19686"},"html":{"href":"https://github.com/rails/rails/pull/19686"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/19686"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/19686/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/19686/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/19686/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/1976af5ac782a85e1afc6fc7d069bbc8ed60226b"}}}}