{"action":"closed","issue":{"url":"https://api.github.com/repos/shuheiktgw/todo_list/issues/16","repository_url":"https://api.github.com/repos/shuheiktgw/todo_list","labels_url":"https://api.github.com/repos/shuheiktgw/todo_list/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/shuheiktgw/todo_list/issues/16/comments","events_url":"https://api.github.com/repos/shuheiktgw/todo_list/issues/16/events","html_url":"https://github.com/shuheiktgw/todo_list/issues/16","id":142143329,"number":16,"title":"group_membersが同じグループ、同じユーザに複数できないようにブロックする","user":{"login":"ms2sato","id":627817,"avatar_url":"https://avatars.githubusercontent.com/u/627817?v=3","gravatar_id":"","url":"https://api.github.com/users/ms2sato","html_url":"https://github.com/ms2sato","followers_url":"https://api.github.com/users/ms2sato/followers","following_url":"https://api.github.com/users/ms2sato/following{/other_user}","gists_url":"https://api.github.com/users/ms2sato/gists{/gist_id}","starred_url":"https://api.github.com/users/ms2sato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ms2sato/subscriptions","organizations_url":"https://api.github.com/users/ms2sato/orgs","repos_url":"https://api.github.com/users/ms2sato/repos","events_url":"https://api.github.com/users/ms2sato/events{/privacy}","received_events_url":"https://api.github.com/users/ms2sato/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-20T09:07:57Z","updated_at":"2016-03-21T01:22:06Z","closed_at":"2016-03-21T01:22:06Z","body":"今は同一グループに、同一ユーザが複数存在できてしまいます。\r\nこれを防ぐにはどうしたらよいでしょうか。rubyのコード、DBのスキーマの、二つの切り口で考えてください。スキーマの方はsqliteでは確認できないので、調査してみてください。\r\n\r\n```\r\nirb(main):006:0> Group.find(2).group_members\r\n  Group Load (0.1ms)  SELECT  \"groups\".* FROM \"groups\" WHERE \"groups\".\"id\" = ? LIMIT 1  [[\"id\", 2]]\r\n  GroupMember Load (0.2ms)  SELECT \"group_members\".* FROM \"group_members\" WHERE \"group_members\".\"group_id\" = ?  [[\"group_id\", 2]]\r\n=> #<ActiveRecord::Associations::CollectionProxy [#<GroupMember id: 5, user_id: 1, group_id: 2, role: 0, created_at: \"2016-03-20 08:35:51\", updated_at: \"2016-03-20 08:35:51\">, #<GroupMember id: 6, user_id: 1, group_id: 2, role: 1, created_at: \"2016-03-20 08:35:51\", updated_at: \"2016-03-20 08:35:51\">, #<GroupMember id: 11, user_id: 1, group_id: 2, role: 0, created_at: \"2016-03-20 09:09:33\", updated_at: \"2016-03-20 09:09:33\">, #<GroupMember id: 12, user_id: 1, group_id: 2, role: 0, created_at: \"2016-03-20 09:09:36\", updated_at: \"2016-03-20 09:09:36\">]>\r\nirb(main):007:0> \r\n```"}}