{"action":"opened","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18311","labels_url":"https://api.github.com/repos/rails/rails/issues/18311/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18311/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18311/events","html_url":"https://github.com/rails/rails/issues/18311","id":53303989,"number":18311,"title":"Nested model size is +1 bigger when you declare it inside controller","user":{"login":"manorie","id":1708139,"avatar_url":"https://avatars.githubusercontent.com/u/1708139?v=3","gravatar_id":"","url":"https://api.github.com/users/manorie","html_url":"https://github.com/manorie","followers_url":"https://api.github.com/users/manorie/followers","following_url":"https://api.github.com/users/manorie/following{/other_user}","gists_url":"https://api.github.com/users/manorie/gists{/gist_id}","starred_url":"https://api.github.com/users/manorie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manorie/subscriptions","organizations_url":"https://api.github.com/users/manorie/orgs","repos_url":"https://api.github.com/users/manorie/repos","events_url":"https://api.github.com/users/manorie/events{/privacy}","received_events_url":"https://api.github.com/users/manorie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-03T13:20:59Z","updated_at":"2015-01-03T13:20:59Z","closed_at":null,"body":"I have two models, \r\n\r\nclass Donkey < ActiveRecord::Base\r\n  has_many :comments, dependent: :destroy\r\n  validates :name, :surname, :age, presence: true \r\nend\r\n\r\nclass Comment < ActiveRecord::Base\r\n  belongs_to :donkey\r\n  validates :comment, :commenter, presence: true\r\nend\r\n\r\nThe problem I have found is,\r\n\r\nWhen you declare,\r\n@comment = @donkey.comments.build inside Donkey controller, the size of @donkey.comments is +1 bigger. For instance if we do not have any comment record, the size of @donkey.comments is 1.\r\n\r\nBut when I declare it inside form_for <%= form_for([@donkey, @donkey.comments.build]) do |f| %> versus <%= form_for([@donkey, @comment]) do |f| %> that problem disappears. \r\n\r\nWhy do we have to declare @comment inside view file rather than controller.\r\n\r\nThanks for your time and making rails better everyday.\r\n"}}