質問編集履歴
2
tweetsコントローラーのソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,7 +94,9 @@
|
|
94
94
|
|
95
95
|
|
96
96
|
|
97
|
+
Outputsコントローラー
|
98
|
+
|
97
|
-
|
99
|
+
createアクションにはurlの下11桁を取得するよう設定しました。
|
98
100
|
|
99
101
|
```
|
100
102
|
|
@@ -140,6 +142,74 @@
|
|
140
142
|
|
141
143
|
|
142
144
|
|
145
|
+
tweetsコントローラー
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
class TweetsController < ApplicationController
|
150
|
+
|
151
|
+
before_action :move_to_index, except: [:index, :show]
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
def index
|
156
|
+
|
157
|
+
@tweets = Tweet.includes(:user)
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
def new
|
164
|
+
|
165
|
+
@tweet = Tweet.new
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
def create
|
172
|
+
|
173
|
+
Tweet.create(tweet_params)
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
def show
|
180
|
+
|
181
|
+
@tweet = Tweet.find(params[:id])
|
182
|
+
|
183
|
+
@output = Output.new
|
184
|
+
|
185
|
+
@outputs = @tweet.outputs.includes(:user)
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
def tweet_params
|
194
|
+
|
195
|
+
params.require(:tweet).permit(:nickname, :text).merge(user_id: current_user.id)
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
def move_to_index
|
202
|
+
|
203
|
+
redirect_to action: :index unless user_signed_in?
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
```
|
210
|
+
|
211
|
+
|
212
|
+
|
143
213
|
マイグレーションファイルではyoutube_urlカラムで、stringタイプです。
|
144
214
|
|
145
215
|
```db/migrate/20200331065035_create_outputs.rb
|
@@ -170,7 +240,7 @@
|
|
170
240
|
|
171
241
|
|
172
242
|
|
173
|
-
検証ツールでは、urlが完全に取得されていない模様
|
243
|
+
検証ツールでは、url下11桁が完全に取得されていない模様。
|
174
244
|
|
175
245
|
[gyazo](https://gyazo.com/0ea9cf47019d08e7ba7745fb8f42d33f)
|
176
246
|
|
1
タイトル編集
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Railsで投稿したYouTubeの動画
|
1
|
+
Railsで投稿したYouTubeの動画が再生できない
|
test
CHANGED
File without changes
|