{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/31891","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/31891/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/31891/comments","events_url":"https://api.github.com/repos/rails/rails/issues/31891/events","html_url":"https://github.com/rails/rails/issues/31891","id":294339592,"number":31891,"title":"Rails, polymorphic association. Destroy with \"touch: true\", useless steps.","user":{"login":"johnunclesam","id":21275217,"avatar_url":"https://avatars3.githubusercontent.com/u/21275217?v=4","gravatar_id":"","url":"https://api.github.com/users/johnunclesam","html_url":"https://github.com/johnunclesam","followers_url":"https://api.github.com/users/johnunclesam/followers","following_url":"https://api.github.com/users/johnunclesam/following{/other_user}","gists_url":"https://api.github.com/users/johnunclesam/gists{/gist_id}","starred_url":"https://api.github.com/users/johnunclesam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnunclesam/subscriptions","organizations_url":"https://api.github.com/users/johnunclesam/orgs","repos_url":"https://api.github.com/users/johnunclesam/repos","events_url":"https://api.github.com/users/johnunclesam/events{/privacy}","received_events_url":"https://api.github.com/users/johnunclesam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-05T10:18:44Z","updated_at":"2018-02-07T00:13:34Z","closed_at":null,"author_association":"NONE","body":"I'm on **Rails 5**.\r\n\r\nI have a polymorphic association like this:\r\n\r\n*models/enjoy_level.rb*:\r\n\r\n    class EnjoyLevel < ApplicationRecord\r\n      belongs_to :enjoyable, polymorphic: true, touch: true, optional: true\r\n    end\r\n\r\n*models/mother.rb*:\r\n\r\n    class Mother < ApplicationRecord\r\n      has_one :enjoy_level, as: :enjoyable, dependent: :destroy\r\n    \r\n      accepts_nested_attributes_for :enjoy_level\r\n    end\r\n\r\nIf I destroy one `mother` (which have `touch: true` option) it still:\r\n\r\n- destroy the `enjoy_level` one before;\r\n- set `Mother` `update_at` to now();\r\n- and finally destroy this `Mother` record one.\r\n\r\n**The first and second steps are useless**, right?\r\n\r\nWhere am I wrong?\r\n\r\n### System configuration\r\n**Rails version**: 5.1.4\r\n**Ruby version**: 2.5.0\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/363610893","html_url":"https://github.com/rails/rails/issues/31891#issuecomment-363610893","issue_url":"https://api.github.com/repos/rails/rails/issues/31891","id":363610893,"user":{"login":"noma4i","id":210667,"avatar_url":"https://avatars2.githubusercontent.com/u/210667?v=4","gravatar_id":"","url":"https://api.github.com/users/noma4i","html_url":"https://github.com/noma4i","followers_url":"https://api.github.com/users/noma4i/followers","following_url":"https://api.github.com/users/noma4i/following{/other_user}","gists_url":"https://api.github.com/users/noma4i/gists{/gist_id}","starred_url":"https://api.github.com/users/noma4i/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noma4i/subscriptions","organizations_url":"https://api.github.com/users/noma4i/orgs","repos_url":"https://api.github.com/users/noma4i/repos","events_url":"https://api.github.com/users/noma4i/events{/privacy}","received_events_url":"https://api.github.com/users/noma4i/received_events","type":"User","site_admin":false},"created_at":"2018-02-07T00:13:34Z","updated_at":"2018-02-07T00:13:34Z","author_association":"NONE","body":"@eileencodes I think I know he is trying to explain. Check my gist https://gist.github.com/noma4i/3034ac3776cdfea2730f2ca81dd3f836\r\n\r\nYou can see that rails from master has 6 queries overall for that test while 5.1.5.rc1 will use 7 sql queries generating one useless SELECT statement so my assert will pass on master while failing for 5.1.*\r\n\r\nflip `gem 'rails'` in my test suite to see the problem."}}
{"actor":{"display_login":"noma4i"}}