質問編集履歴
3
ルートの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -49,6 +49,15 @@
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
Rails.application.routes.draw do
|
53
|
+
root 'comments#new'
|
54
|
+
resources :comments do
|
55
|
+
collection do
|
56
|
+
post 'purchase'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
60
|
+
end
|
52
61
|
```
|
53
62
|
|
54
63
|
### 試したこと
|
2
コントローラーの記入
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,15 +11,48 @@
|
|
11
11
|
### 該当のソースコード
|
12
12
|
|
13
13
|
```ここに言語名を入力
|
14
|
-
|
14
|
+
<%= form_tag('/comments', method: :post) do %>
|
15
15
|
<input type="string" name="address"placeholder="メールアドレス、連絡先"></input>
|
16
16
|
<textarea type="text" name="comment" placeholder= "内容"></textarea>
|
17
17
|
<input class=btn type="submit" value="送信">
|
18
18
|
<%end%>
|
19
|
+
|
20
|
+
class CommentsController < ApplicationController
|
21
|
+
def new
|
22
|
+
@comments=Comment.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def show
|
26
|
+
@comments =Comment.all
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
Comment.create(comment_params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def destry
|
34
|
+
@comments = Comment.find(params[:id])
|
35
|
+
end
|
36
|
+
|
37
|
+
def purchase
|
38
|
+
Payjp.api_key = ENV["PAYJP_SECRET_KEY"]
|
39
|
+
Payjp::Charge.create(
|
40
|
+
:amount => 500,
|
41
|
+
:card => params['payjp-token'],
|
42
|
+
:currency => 'jpy'
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def comment_params
|
48
|
+
params.permit(:comment, :address)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
19
52
|
```
|
20
53
|
|
21
54
|
### 試したこと
|
22
55
|
|
23
|
-
binding.pry
|
56
|
+
binding.pryをしましたが変化はありませんでした。
|
24
57
|
|
25
58
|
### 補足情報(FW/ツールのバージョンなど)
|
1
ソースコードの記入
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,9 +9,13 @@
|
|
9
9
|
```
|
10
10
|
|
11
11
|
### 該当のソースコード
|
12
|
-
|
12
|
+
|
13
13
|
```ここに言語名を入力
|
14
|
+
ソースコード <%= form_tag('/comments', method: :post) do %>
|
15
|
+
<input type="string" name="address"placeholder="メールアドレス、連絡先"></input>
|
16
|
+
<textarea type="text" name="comment" placeholder= "内容"></textarea>
|
17
|
+
<input class=btn type="submit" value="送信">
|
14
|
-
|
18
|
+
<%end%>
|
15
19
|
```
|
16
20
|
|
17
21
|
### 試したこと
|