質問編集履歴
7
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -222,7 +222,7 @@
|
|
222
222
|
|
223
223
|
### エラーのでるソースコード
|
224
224
|
|
225
|
-
home.html.erb
|
225
|
+
/sample_app/app/views/static_pages/home.html.erb
|
226
226
|
|
227
227
|
```ここに言語名を入力
|
228
228
|
|
6
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -238,7 +238,7 @@
|
|
238
238
|
|
239
239
|
```
|
240
240
|
|
241
|
-
_user_logged_in.html.erb
|
241
|
+
/sample_app/app/views/static_pages/_user_logged_in.html.erb
|
242
242
|
|
243
243
|
```
|
244
244
|
|
@@ -272,7 +272,7 @@
|
|
272
272
|
|
273
273
|
```
|
274
274
|
|
275
|
-
_user_not_logged_in.html.erb
|
275
|
+
/sample_app/app/views/static_pages/_user_not_logged_in.html.erb
|
276
276
|
|
277
277
|
```
|
278
278
|
|
@@ -302,7 +302,7 @@
|
|
302
302
|
|
303
303
|
###エラーのでないソースコード
|
304
304
|
|
305
|
-
home.html.erb
|
305
|
+
/sample_app/app/views/static_pages/home.html.erb
|
306
306
|
|
307
307
|
```
|
308
308
|
|
5
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
```
|
38
38
|
|
39
|
-
###他コード
|
39
|
+
###他参考コード
|
40
40
|
|
41
41
|
micropost_controller.rb
|
42
42
|
|
@@ -158,6 +158,66 @@
|
|
158
158
|
|
159
159
|
```
|
160
160
|
|
161
|
+
_user_info.html.erb
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
<%= link_to gravatar_for(current_user, size: 50), current_user %>
|
166
|
+
|
167
|
+
<h1><%= current_user.name %></h1>
|
168
|
+
|
169
|
+
<span><%= link_to "view my profile", current_user %></span>
|
170
|
+
|
171
|
+
<span><%= pluralize(current_user.microposts.count, "micropost") %></span>
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
_micropost_form.html.erb
|
176
|
+
|
177
|
+
```
|
178
|
+
|
179
|
+
<%= form_with(model: @micropost, local: true) do |f| %>
|
180
|
+
|
181
|
+
<%= render 'shared/error_messages', object: f.object %>
|
182
|
+
|
183
|
+
<div class="field">
|
184
|
+
|
185
|
+
<%= f.text_area :content, placeholder: "Compose new micropost..." %>
|
186
|
+
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<%= f.submit "Post", class: "btn btn-primary" %>
|
190
|
+
|
191
|
+
<span class="image">
|
192
|
+
|
193
|
+
<%= f.file_field :image %>
|
194
|
+
|
195
|
+
</span>
|
196
|
+
|
197
|
+
<% end %>
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
_feed.html.erb
|
202
|
+
|
203
|
+
```
|
204
|
+
|
205
|
+
<% if @feed_items.any? %>
|
206
|
+
|
207
|
+
<ol class="microposts">
|
208
|
+
|
209
|
+
<%= render @feed_items %>
|
210
|
+
|
211
|
+
</ol>
|
212
|
+
|
213
|
+
<%= will_paginate @feed_items,
|
214
|
+
|
215
|
+
params: { controller: :static_pages, action: :home } %>
|
216
|
+
|
217
|
+
<% end %>
|
218
|
+
|
219
|
+
```
|
220
|
+
|
161
221
|
|
162
222
|
|
163
223
|
### エラーのでるソースコード
|
4
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -198,12 +198,6 @@
|
|
198
198
|
|
199
199
|
</section>
|
200
200
|
|
201
|
-
<%= link_to image_tag("izumo.jpg", alt: "Rails logo", width: "350px"),
|
202
|
-
|
203
|
-
"https://twitter.com/Izu1202D" %>
|
204
|
-
|
205
|
-
<h3>↑クリック</h3></h3>
|
206
|
-
|
207
201
|
</aside>
|
208
202
|
|
209
203
|
<div class="col-md-8">
|
@@ -244,12 +238,6 @@
|
|
244
238
|
|
245
239
|
</div>
|
246
240
|
|
247
|
-
|
248
|
-
|
249
|
-
<%= link_to image_tag("izumo.jpg", alt: "Rails logo", width: "500px"),
|
250
|
-
|
251
|
-
"https://twitter.com/Izu1202D" %>
|
252
|
-
|
253
241
|
```
|
254
242
|
|
255
243
|
###エラーのでないソースコード
|
3
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,9 @@
|
|
36
36
|
|
37
37
|
```
|
38
38
|
|
39
|
+
###他コード
|
40
|
+
|
39
|
-
|
41
|
+
micropost_controller.rb
|
40
42
|
|
41
43
|
```class MicropostsController < ApplicationController
|
42
44
|
|
@@ -76,6 +78,86 @@
|
|
76
78
|
|
77
79
|
```
|
78
80
|
|
81
|
+
microposts_interface_test
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
require 'test_helper'
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
class MicropostsInterfaceTest < ActionDispatch::IntegrationTest
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
def setup
|
94
|
+
|
95
|
+
@user = users(:michael)
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
test "micropost interface" do
|
102
|
+
|
103
|
+
log_in_as(@user)
|
104
|
+
|
105
|
+
get root_path
|
106
|
+
|
107
|
+
assert_select 'div.pagination'
|
108
|
+
|
109
|
+
# 無効な送信
|
110
|
+
|
111
|
+
assert_no_difference 'Micropost.count' do
|
112
|
+
|
113
|
+
post microposts_path, params: { micropost: { content: "" } }
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
assert_select 'div#error_explanation'
|
118
|
+
|
119
|
+
assert_select 'a[href=?]', '/?page=2' # 正しいページネーションリンク
|
120
|
+
|
121
|
+
# 有効な送信
|
122
|
+
|
123
|
+
content = "This micropost really ties the room together"
|
124
|
+
|
125
|
+
assert_difference 'Micropost.count', 1 do
|
126
|
+
|
127
|
+
post microposts_path, params: { micropost: { content: content } }
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
assert_redirected_to root_url
|
132
|
+
|
133
|
+
follow_redirect!
|
134
|
+
|
135
|
+
assert_match content, response.body
|
136
|
+
|
137
|
+
# 投稿を削除する
|
138
|
+
|
139
|
+
assert_select 'a', text: 'delete'
|
140
|
+
|
141
|
+
first_micropost = @user.microposts.paginate(page: 1).first
|
142
|
+
|
143
|
+
assert_difference 'Micropost.count', -1 do
|
144
|
+
|
145
|
+
delete micropost_path(first_micropost)
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
# 違うユーザーのプロフィールにアクセス(削除リンクがないことを確認)
|
150
|
+
|
151
|
+
get user_path(users(:archer))
|
152
|
+
|
153
|
+
assert_select 'a', text: 'delete', count: 0
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
```
|
160
|
+
|
79
161
|
|
80
162
|
|
81
163
|
### エラーのでるソースコード
|
2
誤字
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails tutorial 第13章 13.3.5 リスト13,57テスト時のエラー home.html.erbでパーシャルを使用した場合
|
1
|
+
誤字rails tutorial 第13章 13.3.5 リスト13,57テスト時のエラー home.html.erbでパーシャルを使用した場合
|
test
CHANGED
@@ -36,6 +36,46 @@
|
|
36
36
|
|
37
37
|
```
|
38
38
|
|
39
|
+
###micropost_controller.rb
|
40
|
+
|
41
|
+
```class MicropostsController < ApplicationController
|
42
|
+
|
43
|
+
before_action :logged_in_user, only: [:create, :destroy]
|
44
|
+
|
45
|
+
before_action :correct_user, only: :destroy
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
def create
|
50
|
+
|
51
|
+
@micropost = current_user.microposts.build(micropost_params)
|
52
|
+
|
53
|
+
if @micropost.save
|
54
|
+
|
55
|
+
flash[:success] = "Micropost created!"
|
56
|
+
|
57
|
+
redirect_to root_url
|
58
|
+
|
59
|
+
else
|
60
|
+
|
61
|
+
@feed_items = current_user.feed.paginate(page: params[:page])
|
62
|
+
|
63
|
+
render 'static_pages/home'
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
.
|
70
|
+
|
71
|
+
.
|
72
|
+
|
73
|
+
.
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```
|
78
|
+
|
39
79
|
|
40
80
|
|
41
81
|
### エラーのでるソースコード
|
@@ -96,7 +136,7 @@
|
|
96
136
|
|
97
137
|
```
|
98
138
|
|
99
|
-
_user_not_logged_in.html
|
139
|
+
_user_not_logged_in.html.erb
|
100
140
|
|
101
141
|
```
|
102
142
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
### エラーのでるソースコード
|
42
42
|
|
43
|
-
home.html
|
43
|
+
home.html.erb
|
44
44
|
|
45
45
|
```ここに言語名を入力
|
46
46
|
|