{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18376","labels_url":"https://api.github.com/repos/rails/rails/issues/18376/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18376/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18376/events","html_url":"https://github.com/rails/rails/issues/18376","id":53581990,"number":18376,"title":"Rails 3.2.21 `:has_many` behaviour difference when Ruby 2.1.5 and Ruby 2.2.0","user":{"login":"ivar","id":4298,"avatar_url":"https://avatars.githubusercontent.com/u/4298?v=3","gravatar_id":"","url":"https://api.github.com/users/ivar","html_url":"https://github.com/ivar","followers_url":"https://api.github.com/users/ivar/followers","following_url":"https://api.github.com/users/ivar/following{/other_user}","gists_url":"https://api.github.com/users/ivar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivar/subscriptions","organizations_url":"https://api.github.com/users/ivar/orgs","repos_url":"https://api.github.com/users/ivar/repos","events_url":"https://api.github.com/users/ivar/events{/privacy}","received_events_url":"https://api.github.com/users/ivar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-07T00:26:04Z","updated_at":"2015-01-07T19:54:31Z","closed_at":"2015-01-07T00:31:15Z","body":"Somehow the `#size` method of an Array returned via a `:has_many through:` association breaks when run under Ruby 2.2.0.  \r\n\r\nRails console with Ruby 2.2.0p0\r\n```\r\nLoading development environment (Rails 3.2.21)\r\ndevelopment (main):0 > a = Property::Agent.last\r\n  Property::Agent Load (1.0ms)  SELECT \"property_agents\".* FROM \"property_agents\" ORDER BY \"property_agents\".\"id\" DESC LIMIT 1\r\n=> #<Property::Agent id: 73624>\r\ndevelopment (main):0 > a.geographies\r\n  Geography Load (6.0ms)  SELECT \"geographies\".* FROM \"geographies\" INNER JOIN \"property_agent_locations\" ON \"geographies\".\"id\" = \"property_agent_locations\".\"geography_id\" WHERE \"property_agent_locations\".\"agent_id\" = 73624\r\n=> []\r\ndevelopment (main):0 > a.geographies.size\r\nNoMethodError: undefined method `name' for nil:NilClass\r\nfrom /home/rew/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-3.2.21/lib/active_record/associations/has_many_association.rb:58:in `cached_counter_attribute_name'\r\ndevelopment (main):0 > a.geographies.count\r\n   (1.2ms)  SELECT COUNT(*) FROM \"geographies\" INNER JOIN \"property_agent_locations\" ON \"geographies\".\"id\" = \"property_agent_locations\".\"geography_id\" WHERE \"property_agent_locations\".\"agent_id\" = 73624\r\n=> 0\r\ndevelopment (main):0 > a.geographies.try(:size)\r\n=> 0\r\ndevelopment (main):0 > a.geographies.class\r\n=> Array\r\ndevelopment (main):0 > ar = []\r\n=> []\r\ndevelopment (main):0 > ar.size\r\n=> 0\r\n```\r\n\r\nand to sanity check, here's using ruby 2.1.5p273\r\n```\r\nLoading development environment (Rails 3.2.21)\r\ndevelopment (main):0 > a = Property::Agent.last\r\n  Property::Agent Load (148.3ms)  SELECT \"property_agents\".* FROM \"property_agents\" ORDER BY \"property_agents\".\"id\" DESC LIMIT 1\r\n=> #<Property::Agent id: 73624>\r\ndevelopment (main):0 > a.geographies\r\n  Geography Load (20.8ms)  SELECT \"geographies\".* FROM \"geographies\" INNER JOIN \"property_agent_locations\" ON \"geographies\".\"id\" = \"property_agent_locations\".\"geography_id\" WHERE \"property_agent_locations\".\"agent_id\" = 73624\r\n=> []\r\ndevelopment (main):0 > a.geographies.size\r\n=> 0\r\ndevelopment (main):0 > a.geographies.count\r\n   (0.8ms)  SELECT COUNT(*) FROM \"geographies\" INNER JOIN \"property_agent_locations\" ON \"geographies\".\"id\" = \"property_agent_locations\".\"geography_id\" WHERE \"property_agent_locations\".\"agent_id\" = 73624\r\n=> 0\r\n```"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/69081148","html_url":"https://github.com/rails/rails/issues/18376#issuecomment-69081148","issue_url":"https://api.github.com/repos/rails/rails/issues/18376","id":69081148,"user":{"login":"ivar","id":4298,"avatar_url":"https://avatars.githubusercontent.com/u/4298?v=3","gravatar_id":"","url":"https://api.github.com/users/ivar","html_url":"https://github.com/ivar","followers_url":"https://api.github.com/users/ivar/followers","following_url":"https://api.github.com/users/ivar/following{/other_user}","gists_url":"https://api.github.com/users/ivar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivar/subscriptions","organizations_url":"https://api.github.com/users/ivar/orgs","repos_url":"https://api.github.com/users/ivar/repos","events_url":"https://api.github.com/users/ivar/events{/privacy}","received_events_url":"https://api.github.com/users/ivar/received_events","type":"User","site_admin":false},"created_at":"2015-01-07T19:54:31Z","updated_at":"2015-01-07T19:54:31Z","body":"@rafaelfranca I tested with 37f2defa99 (`3-2-stable` HEAD)  and the issue is fixed!\r\nThanks so much for your time support us laggards.\r\n\r\n"}}