質問編集履歴
2
tweetsコントローラーのソースコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -46,7 +46,8 @@
|
|
46
46
|
= output.user.nickname
|
47
47
|
```
|
48
48
|
|
49
|
+
Outputsコントローラー
|
49
|
-
|
50
|
+
createアクションにはurlの下11桁を取得するよう設定しました。
|
50
51
|
```
|
51
52
|
class OutputsController < ApplicationController
|
52
53
|
|
@@ -69,6 +70,40 @@
|
|
69
70
|
end
|
70
71
|
```
|
71
72
|
|
73
|
+
tweetsコントローラー
|
74
|
+
```
|
75
|
+
class TweetsController < ApplicationController
|
76
|
+
before_action :move_to_index, except: [:index, :show]
|
77
|
+
|
78
|
+
def index
|
79
|
+
@tweets = Tweet.includes(:user)
|
80
|
+
end
|
81
|
+
|
82
|
+
def new
|
83
|
+
@tweet = Tweet.new
|
84
|
+
end
|
85
|
+
|
86
|
+
def create
|
87
|
+
Tweet.create(tweet_params)
|
88
|
+
end
|
89
|
+
|
90
|
+
def show
|
91
|
+
@tweet = Tweet.find(params[:id])
|
92
|
+
@output = Output.new
|
93
|
+
@outputs = @tweet.outputs.includes(:user)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
def tweet_params
|
98
|
+
params.require(:tweet).permit(:nickname, :text).merge(user_id: current_user.id)
|
99
|
+
end
|
100
|
+
|
101
|
+
def move_to_index
|
102
|
+
redirect_to action: :index unless user_signed_in?
|
103
|
+
end
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
72
107
|
マイグレーションファイルではyoutube_urlカラムで、stringタイプです。
|
73
108
|
```db/migrate/20200331065035_create_outputs.rb
|
74
109
|
class CreateOutputs < ActiveRecord::Migration[5.2]
|
@@ -84,7 +119,7 @@
|
|
84
119
|
end
|
85
120
|
```
|
86
121
|
|
87
|
-
検証ツールでは、urlが完全に取得されていない模様
|
122
|
+
検証ツールでは、url下11桁が完全に取得されていない模様。
|
88
123
|
[gyazo](https://gyazo.com/0ea9cf47019d08e7ba7745fb8f42d33f)
|
89
124
|
|
90
125
|
# 補足情報(FW/ツールのバージョンなど)
|
1
タイトル編集
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Railsで投稿したYouTubeの動画
|
1
|
+
Railsで投稿したYouTubeの動画が再生できない
|
body
CHANGED
File without changes
|