質問編集履歴

3

開発環境を追加

2019/10/03 11:53

投稿

juichiro
juichiro

スコア19

test CHANGED
File without changes
test CHANGED
@@ -87,3 +87,7 @@
87
87
  Rendering calculators/result.html.slim within layouts/application Rendered calculators/result.html.slim within layouts/application (2.0ms)
88
88
 
89
89
  Completed 200 OK in 20ms (Views: 16.8ms | ActiveRecord: 0.0ms)
90
+
91
+ #開発環境
92
+
93
+ #####cloud9/mysql/rails 5.2.3/ruby2.6.3p62

2

new.html.slim の記述を少し間違っていたため修正

2019/10/03 11:53

投稿

juichiro
juichiro

スコア19

test CHANGED
File without changes
test CHANGED
@@ -66,7 +66,7 @@
66
66
 
67
67
  #result.html.slim(new.html.slimから送られてきたフォームの中身を表示したい。
68
68
 
69
- @number
69
+ = @number
70
70
 
71
71
 
72
72
 

1

関連のあるファイルとコードの追加をしました!

2019/10/03 11:41

投稿

juichiro
juichiro

スコア19

test CHANGED
File without changes
test CHANGED
@@ -29,3 +29,61 @@
29
29
  Rendered calculators/result.html.slim within layouts/application (2.0ms)
30
30
 
31
31
  Completed 200 OK in 23ms (Views: 19.9ms | ActiveRecord: 0.0ms)
32
+
33
+ #追記
34
+
35
+ #new.html.slim(submitを押してもページが変わらない)
36
+
37
+ h1 飲んだビールの本数を入力!
38
+
39
+
40
+
41
+ = form_with url: calculators_result_path do |f|
42
+
43
+ = f.label :number, '本数'
44
+
45
+ = f.number_field :number
46
+
47
+ = f.submit
48
+
49
+ #calculators_controller.rb 
50
+
51
+ class CalculatorsController < ApplicationController
52
+
53
+ def new
54
+
55
+ @calculator = Calculator.new
56
+
57
+ end
58
+
59
+ def result
60
+
61
+ @number = params[:number]
62
+
63
+ end
64
+
65
+ end
66
+
67
+ #result.html.slim(new.html.slimから送られてきたフォームの中身を表示したい。
68
+
69
+ @number 本
70
+
71
+
72
+
73
+ #ログにまたcannnot render console from 217.178.13.68 と表示される。
74
+
75
+ もう一度確認したところ、またcannot render console from 217.178.13.68 と表示されるようになってしまいました。しかし from以降の番号が以前と違います。
76
+
77
+
78
+
79
+ Started POST "/calculators/result" for 217.178.13.68 at 2019-10-03 11:07:22 +0000
80
+
81
+ Cannot render console from 217.178.13.68! Allowed networks: 103.5.142.234, 127.0.0.0/127.255.255.255, ::1
82
+
83
+ Processing by CalculatorsController#result as JS
84
+
85
+ Parameters: {"utf8"=>"✓", "authenticity_token"=>"37OBGzhA/g48OdXXS0QI4HwezK8cCKN5dCE4JpDbtxNFhs38EZDZmIDeChMVtDf4HGDSaNYn3iUHLsummsFOJQ==", "number"=>"1", "commit"=>"Save "}
86
+
87
+ Rendering calculators/result.html.slim within layouts/application Rendered calculators/result.html.slim within layouts/application (2.0ms)
88
+
89
+ Completed 200 OK in 20ms (Views: 16.8ms | ActiveRecord: 0.0ms)