質問編集履歴
3
1.routes.rbに欠けていたコードとstaticpagescontrollerを追記しました。2.ファイルの場所には中黒を付けました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,8 +14,6 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
ターミナル上で
|
18
|
-
|
19
17
|
$ rails _5.1.6_ new sample_app
|
20
18
|
|
21
19
|
|
@@ -104,7 +102,7 @@
|
|
104
102
|
|
105
103
|
|
106
104
|
|
107
|
-
|
105
|
+
|
108
106
|
|
109
107
|
$ bundle install --without production
|
110
108
|
|
@@ -122,6 +120,8 @@
|
|
122
120
|
|
123
121
|
次に、コントローラーとルートの設定
|
124
122
|
|
123
|
+
- app/controllers/application_controller.rb
|
124
|
+
|
125
125
|
```Ruby
|
126
126
|
|
127
127
|
class ApplicationController < ActionController::Base
|
@@ -140,19 +140,53 @@
|
|
140
140
|
|
141
141
|
```
|
142
142
|
|
143
|
+
- config/routes.rb
|
144
|
+
|
143
145
|
```Ruby
|
144
146
|
|
145
147
|
Rails.application.routes.draw do
|
146
148
|
|
149
|
+
get 'static_pages/home'
|
150
|
+
|
151
|
+
get 'static_pages/help'
|
152
|
+
|
147
153
|
root 'application#hello'
|
148
154
|
|
149
155
|
end
|
150
156
|
|
151
157
|
```
|
152
158
|
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
$ rails generate controller StaticPages home help
|
164
|
+
|
165
|
+
- app/controllers/static_pages_controller.rb
|
166
|
+
|
153
|
-
|
167
|
+
```Ruby
|
168
|
+
|
154
|
-
|
169
|
+
class StaticPagesController < ApplicationController
|
170
|
+
|
171
|
+
def home
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
def help
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
```
|
184
|
+
|
185
|
+
(ファイルオープンコマンドで確認済み)
|
186
|
+
|
187
|
+
|
188
|
+
|
155
|
-
$ git commit -am "
|
189
|
+
$ git commit -am "メッセージの内容2"
|
156
190
|
|
157
191
|
$ git push
|
158
192
|
|
@@ -216,7 +250,7 @@
|
|
216
250
|
|
217
251
|
```
|
218
252
|
|
219
|
-
2020-03-03T22:53:53.230551+00:00 app[web.1]: I,
|
253
|
+
2020-03-03T22:53:53.230551+00:00 app[web.1]: I,[2020-03-03T22:53:53.230278 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Started GET "/" for 175.130.222.181 at 2020-03-03 22:53:53 +0000
|
220
254
|
|
221
255
|
2020-03-03T22:53:53.243838+00:00 app[web.1]: I, [2020-03-03T22:53:53.243695 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Processing by ApplicationController#hello as HTML
|
222
256
|
|
2
heroku logを複数行記入しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -216,8 +216,32 @@
|
|
216
216
|
|
217
217
|
```
|
218
218
|
|
219
|
-
2020-03-03T
|
219
|
+
2020-03-03T22:53:53.230551+00:00 app[web.1]: I, [2020-03-03T22:53:53.230278 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Started GET "/" for 175.130.222.181 at 2020-03-03 22:53:53 +0000
|
220
|
+
|
221
|
+
2020-03-03T22:53:53.243838+00:00 app[web.1]: I, [2020-03-03T22:53:53.243695 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Processing by ApplicationController#hello as HTML
|
222
|
+
|
223
|
+
2020-03-03T22:53:53.255226+00:00 app[web.1]: I, [2020-03-03T22:53:53.255097 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Rendering html template
|
224
|
+
|
225
|
+
2020-03-03T22:53:53.255567+00:00 app[web.1]: I, [2020-03-03T22:53:53.255483 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Rendered html template (0.0ms)
|
226
|
+
|
227
|
+
2020-03-03T22:53:53.257171+00:00 app[web.1]: I, [2020-03-03T22:53:53.257081 #4] INFO -- : [730e6aee-90fe-4a7c-91f2-cae91c6d02e6] Completed 200 OK in 12ms (Views: 1.5ms)
|
228
|
+
|
229
|
+
2020-03-03T22:53:53.555613+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=warm-wildwood-90749.herokuapp.com request_id=75611fc8-0e29-4f08-b0e2-7762daedb4e7 fwd="175.130.222.181" dyno=web.1 connect=1ms service=27ms status=304 bytes=48 protocol=https
|
230
|
+
|
231
|
+
2020-03-03T22:55:03.333950+00:00 heroku[router]: at=info method=GET path="/static-pages/home" host=warm-wildwood-90749.herokuapp.com request_id=d2d987ac-5a4f-4eb7-99da-8510a1570b14 fwd="175.130.222.181" dyno=web.1 connect=0ms service=4ms status=404 bytes=1902 protocol=https
|
232
|
+
|
233
|
+
2020-03-03T22:55:03.332590+00:00 app[web.1]: I, [2020-03-03T22:55:03.332462 #4] INFO -- : [d2d987ac-5a4f-4eb7-99da-8510a1570b14] Started GET "/static-pages/home" for 175.130.222.181 at 2020-03-03 22:55:03 +0000
|
234
|
+
|
235
|
+
2020-03-03T22:55:03.334606+00:00 app[web.1]: F, [2020-03-03T22:55:03.334534 #4] FATAL -- : [d2d987ac-5a4f-4eb7-99da-8510a1570b14]
|
236
|
+
|
237
|
+
2020-03-03T22:55:03.334707+00:00 app[web.1]: F, [2020-03-03T22:55:03.334643 #4] FATAL -- : [d2d987ac-5a4f-4eb7-99da-8510a1570b14] ActionController::RoutingError (No route matches [GET] "/static-pages/home"):
|
238
|
+
|
239
|
+
2020-03-03T22:55:03.334793+00:00 app[web.1]: F, [2020-03-03T22:55:03.334733 #4] FATAL -- : [d2d987ac-5a4f-4eb7-99da-8510a1570b14]
|
240
|
+
|
241
|
+
2020-03-03T22:55:03.334918+00:00 app[web.1]: F, [2020-03-03T22:55:03.334838 #4] FATAL -- : [d2d987ac-5a4f-4eb7-99da-8510a1570b14] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
|
220
242
|
|
221
243
|
```
|
222
244
|
|
223
245
|
のようなコードがあったのですがこれが原因でしょうか?
|
246
|
+
|
247
|
+
webページエラーは(404)です。
|
1
heroku logから原因と思われる一文を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -206,4 +206,18 @@
|
|
206
206
|
|
207
207
|
---
|
208
208
|
|
209
|
-
原因も含めて対
|
209
|
+
原因も含めて対処方法を教えてもらえると後学のためになるので宜しくお願い致します。
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
##### 追記
|
214
|
+
|
215
|
+
修正依頼で頂いたheroku logs --tailを打ったら
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
2020-03-03T08:46:35.573681+00:00 app[web.1]: F, [2020-03-03T08:46:35.573605 #4]FATAL -- : [ae82e50e-bc42-424d-afd3-41b861e24166] ActionController::RoutingError (No route matches [GET] "/static-pages/home"):
|
220
|
+
|
221
|
+
```
|
222
|
+
|
223
|
+
のようなコードがあったのですがこれが原因でしょうか?
|