teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

controllerの追記

2020/02/14 02:44

投稿

KOO_
KOO_

スコア58

title CHANGED
File without changes
body CHANGED
@@ -39,6 +39,7 @@
39
39
  よろしくお願い致します。
40
40
 
41
41
 
42
+ ```controller
42
43
 
43
44
  class ContactController < ApplicationController
44
45
  layout "app"
@@ -67,4 +68,5 @@
67
68
  :subsidy
68
69
  )
69
70
  end
70
- end
71
+ end
72
+ ```

1

controller追加

2020/02/14 02:44

投稿

KOO_
KOO_

スコア58

title CHANGED
File without changes
body CHANGED
@@ -36,4 +36,35 @@
36
36
  end
37
37
  ```
38
38
 
39
- よろしくお願い致します。
39
+ よろしくお願い致します。
40
+
41
+
42
+
43
+ class ContactController < ApplicationController
44
+ layout "app"
45
+ def index
46
+ @contact = Contact.new
47
+ render :action => 'index'
48
+ end
49
+
50
+ def confirm
51
+ @contact = Contact.new(contact_params)
52
+ if @contact.valid?
53
+ render :action => 'confirm'
54
+ else
55
+ render :action => 'index'
56
+ end
57
+ end
58
+
59
+ def thanks
60
+ @contact = Contact.new(contact_params)
61
+ ContactMailer.received_email(@contact).deliver
62
+ end
63
+
64
+ private
65
+ def contact_params
66
+ params.require(:contact).permit(
67
+ :subsidy
68
+ )
69
+ end
70
+ end