teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

追記

2021/04/21 19:21

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -33,4 +33,20 @@
33
33
  お分かりの方、ぜひ宜しくお願いいたします。
34
34
  ###追記
35
35
  関係性
36
- ![イメージ説明](f34a9cfe6559a972dcb61ef52904bee6.png)
36
+ ![イメージ説明](f34a9cfe6559a972dcb61ef52904bee6.png)
37
+ ```model
38
+ class User < ApplicationRecord
39
+ has_many :groups, through: :group_users
40
+ has_many :group_users
41
+ end
42
+
43
+ class Group < ApplicationRecord
44
+ has_many :users, through: :group_users
45
+ has_many :group_users
46
+ end
47
+
48
+ class GroupUser < ApplicationRecord
49
+ belongs_to :group
50
+ belongs_to :user
51
+ end
52
+ ```

2

追記

2021/04/21 19:21

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -30,4 +30,7 @@
30
30
  t.datetime "updated_at", null: false
31
31
  end
32
32
  ```
33
- お分かりの方、ぜひ宜しくお願いいたします。
33
+ お分かりの方、ぜひ宜しくお願いいたします。
34
+ ###追記
35
+ 関係性
36
+ ![イメージ説明](f34a9cfe6559a972dcb61ef52904bee6.png)

1

修正

2021/04/21 18:55

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -9,12 +9,13 @@
9
9
  ```
10
10
  加えたい内容(以下の様な条件)
11
11
  ```ここに言語を入力
12
- GroupUser.where(created_at: Date.today)
12
+ GroupUser.where(mydate: Date.today)
13
13
  ```
14
14
  ```schema
15
15
  create_table "group_users", force: :cascade do |t|
16
16
  t.integer "group_id"
17
17
  t.integer "user_id"
18
+ t.datetime "mydate"
18
19
  t.datetime "created_at", null: false
19
20
  t.datetime "updated_at", null: false
20
21
  end