質問編集履歴

1

追加の情報

2015/06/22 02:59

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -21,3 +21,63 @@
21
21
 
22
22
 
23
23
  どう対処したらいいですか?
24
+
25
+
26
+
27
+
28
+
29
+ 追記
30
+
31
+
32
+
33
+ 記事を投稿する際にエラーが起こります。(記事は保存されます)
34
+
35
+ メールのセッティングは
36
+
37
+ app/meilers/post_mailer.rb
38
+
39
+
40
+
41
+ default from: "from@example.com"
42
+
43
+ def post_email(user,post)
44
+
45
+ @user = user
46
+
47
+ mail to: "@user.email", subject: "記事を投稿しました。"
48
+
49
+ end
50
+
51
+
52
+
53
+ app/Views/post_mailer/post_email.html.erb
54
+
55
+ app/Views/post_mailer/post_email.text.erb
56
+
57
+ こちらは参考にしたサイトと全く一緒です。
58
+
59
+
60
+
61
+ controllers/posts_controller.rb
62
+
63
+ def create
64
+
65
+ @user=current_user
66
+
67
+ @post =Post.new(post_params)
68
+
69
+ @post.user_id = @user.id
70
+
71
+ if @post.save
72
+
73
+ PostMailer.post_email(@user,@post).deliver
74
+
75
+ redirect_to posts_path
76
+
77
+ else
78
+
79
+ render :new
80
+
81
+ end
82
+
83
+ end