我有一个用户模型(带有设计)和一个属于用户的帖子模型。创建帐户后,我使用此 railscast (pro)向用户发送电子邮件
我创建了一个“NewPostMailer”
这是我的邮件:
class NewPostMailer < ActionMailer::Base
default :from => "email@gmail.com"
def new_post_email(user)
@user = user
@url = "http://localhost.com:3000/users/login"
mail(:to => user.email, :subject => "New Post")
end
end
我的posts_controller:
def create
@post= Post.new(params[:post])
respond_to do |format|
if @deal.save
NewPostMailer.new_post_confirmation(@user).deliver
format.html { redirect_to @post, notice: 'Post was successfully created.' }
post.rb
after_create :send_new_post_email
private
def send_new_post_email
NewPostMailer.new_post_email(self).deliver
end
在用户创建帖子后,我必须更改哪些内容才能向用户发送电子邮件。谢谢。