質問編集履歴
2
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,4 +136,4 @@
|
|
136
136
|
|
137
137
|
追記:
|
138
138
|
|
139
|
-
Tweetモデルのtweet_idがTweetテーブルの
|
139
|
+
Tweetモデルのtweet_idがTweetテーブルのFKにしたいと思います。外に見える部分なので連番にしたくないからです。
|
1
ごじ
test
CHANGED
File without changes
|
test
CHANGED
@@ -37,6 +37,8 @@
|
|
37
37
|
def create
|
38
38
|
|
39
39
|
@tweet = current_user.tweets.new(tweet_params)
|
40
|
+
|
41
|
+
@tweet.tweet_id = SecureRandom.hex(10)
|
40
42
|
|
41
43
|
if @tweet.save
|
42
44
|
|
@@ -118,12 +120,20 @@
|
|
118
120
|
|
119
121
|
**・Tweet**
|
120
122
|
|
121
|
-
|id|tweet_body|created_user_id|created_at|updated_at|
|
123
|
+
|id|tweet_id|tweet_body|created_user_id|created_at|updated_at|
|
122
124
|
|
123
|
-
|:--|:--:|--:|--:|
|
125
|
+
|:--|:--:|--:|--:|--:|
|
124
126
|
|
125
127
|
|
126
128
|
|
127
129
|
となっています。
|
128
130
|
|
129
131
|
Tweetのcreated_user_idに、作成したUserのidを保存する前提です。
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
追記:
|
138
|
+
|
139
|
+
Tweetモデルのtweet_idがTweetテーブルのPKにしたいと思います。外に見える部分なので連番にしたくないからです。
|