質問編集履歴
3
ルートの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -100,6 +100,24 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
+
Rails.application.routes.draw do
|
104
|
+
|
105
|
+
root 'comments#new'
|
106
|
+
|
107
|
+
resources :comments do
|
108
|
+
|
109
|
+
collection do
|
110
|
+
|
111
|
+
post 'purchase'
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
118
|
+
|
119
|
+
end
|
120
|
+
|
103
121
|
```
|
104
122
|
|
105
123
|
|
2
コントローラーの記入
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
```ここに言語名を入力
|
26
26
|
|
27
|
-
|
27
|
+
<%= form_tag('/comments', method: :post) do %>
|
28
28
|
|
29
29
|
<input type="string" name="address"placeholder="メールアドレス、連絡先"></input>
|
30
30
|
|
@@ -34,6 +34,72 @@
|
|
34
34
|
|
35
35
|
<%end%>
|
36
36
|
|
37
|
+
|
38
|
+
|
39
|
+
class CommentsController < ApplicationController
|
40
|
+
|
41
|
+
def new
|
42
|
+
|
43
|
+
@comments=Comment.new
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
def show
|
50
|
+
|
51
|
+
@comments =Comment.all
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
def create
|
58
|
+
|
59
|
+
Comment.create(comment_params)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
def destry
|
66
|
+
|
67
|
+
@comments = Comment.find(params[:id])
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
def purchase
|
74
|
+
|
75
|
+
Payjp.api_key = ENV["PAYJP_SECRET_KEY"]
|
76
|
+
|
77
|
+
Payjp::Charge.create(
|
78
|
+
|
79
|
+
:amount => 500,
|
80
|
+
|
81
|
+
:card => params['payjp-token'],
|
82
|
+
|
83
|
+
:currency => 'jpy'
|
84
|
+
|
85
|
+
)
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def comment_params
|
94
|
+
|
95
|
+
params.permit(:comment, :address)
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
|
37
103
|
```
|
38
104
|
|
39
105
|
|
@@ -42,7 +108,7 @@
|
|
42
108
|
|
43
109
|
|
44
110
|
|
45
|
-
binding.pry
|
111
|
+
binding.pryをしましたが変化はありませんでした。
|
46
112
|
|
47
113
|
|
48
114
|
|
1
ソースコードの記入
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,11 +20,19 @@
|
|
20
20
|
|
21
21
|
### 該当のソースコード
|
22
22
|
|
23
|
-
|
23
|
+
|
24
24
|
|
25
25
|
```ここに言語名を入力
|
26
26
|
|
27
|
+
ソースコード <%= form_tag('/comments', method: :post) do %>
|
28
|
+
|
29
|
+
<input type="string" name="address"placeholder="メールアドレス、連絡先"></input>
|
30
|
+
|
31
|
+
<textarea type="text" name="comment" placeholder= "内容"></textarea>
|
32
|
+
|
33
|
+
<input class=btn type="submit" value="送信">
|
34
|
+
|
27
|
-
|
35
|
+
<%end%>
|
28
36
|
|
29
37
|
```
|
30
38
|
|