質問編集履歴
4
コードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -45,6 +45,12 @@
|
|
45
45
|
end
|
46
46
|
```
|
47
47
|
|
48
|
+
app/models/twet.rb↓
|
49
|
+
```
|
50
|
+
class Tweet < ApplicationRecord
|
51
|
+
end
|
52
|
+
|
53
|
+
```
|
48
54
|
### 試したこと
|
49
55
|
|
50
56
|
マイグレーションファイルの確認、ソースコードの確認
|
3
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|

|
9
9
|
### 該当のソースコード
|
10
|
-
|
10
|
+
new.html.erb↓
|
11
11
|
```
|
12
12
|
<%= form_for(@tweet, :url => { controller:'tweets', action:'create'})do |f| %>
|
13
13
|
<%= f.label :body %>
|
@@ -18,8 +18,7 @@
|
|
18
18
|
<br>
|
19
19
|
<% end %>
|
20
20
|
```
|
21
|
-
|
22
|
-
|
21
|
+
tweets_controller.rb↓
|
23
22
|
```
|
24
23
|
class TweetsController < ApplicationController
|
25
24
|
def index
|
@@ -32,7 +31,7 @@
|
|
32
31
|
end
|
33
32
|
```
|
34
33
|
|
35
|
-
マイグレーションファイル
|
34
|
+
20191218100147_create_tweets.rb (マイグレーションファイル)↓
|
36
35
|
```
|
37
36
|
class CreateTweets < ActiveRecord::Migration[6.0]
|
38
37
|
def change
|
2
コードの画像添付からtextへの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,12 +7,45 @@
|
|
7
7
|
|
8
8
|

|
9
9
|
### 該当のソースコード
|
10
|
+
viewのコード↓
|
11
|
+
```
|
12
|
+
<%= form_for(@tweet, :url => { controller:'tweets', action:'create'})do |f| %>
|
13
|
+
<%= f.label :body %>
|
14
|
+
<br>
|
10
|
-
|
15
|
+
<%= f.text_field :body,size: 140 %>
|
16
|
+
<br>
|
17
|
+
<%= f.submit %>
|
18
|
+
<br>
|
19
|
+
<% end %>
|
20
|
+
```
|
11
21
|
|
22
|
+
コントローラのコード↓
|
23
|
+
```
|
12
|
-
|
24
|
+
class TweetsController < ApplicationController
|
25
|
+
def index
|
26
|
+
end
|
13
27
|
|
28
|
+
def new
|
14
|
-
|
29
|
+
@tweet = Tweet.new
|
30
|
+
end
|
15
31
|
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
マイグレーションファイルのコード↓
|
36
|
+
```
|
37
|
+
class CreateTweets < ActiveRecord::Migration[6.0]
|
38
|
+
def change
|
39
|
+
create_table :tweets do |t|
|
40
|
+
|
41
|
+
t.text :body
|
42
|
+
|
43
|
+
t.timestamps
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
16
49
|
### 試したこと
|
17
50
|
|
18
51
|
マイグレーションファイルの確認、ソースコードの確認
|
1
コントローラのコードとテーブルの構成のコード(マイグレーションファイル)を追加で記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,8 +7,12 @@
|
|
7
7
|
|
8
8
|

|
9
9
|
### 該当のソースコード
|
10
|
-

|
10
|
+
viewのコード↓
|
11
11
|
|
12
|
+
コントローラのコード↓
|
13
|
+
|
14
|
+
マイグレーションファイルのコード↓
|
15
|
+
|
12
16
|
### 試したこと
|
13
17
|
|
14
18
|
マイグレーションファイルの確認、ソースコードの確認
|