我试图在创建事件时向活动用户发送电子邮件。虽然这样做时我收到以下错误
Started POST "/events" for 124.149.85.178 at Sat Jul 07 13:15:03 +0200 2012
Processing by SchedulesController#create as HTML
Parameters: {"utf8"=>"✓", "time"=>{"typedatetimeclassrequired"=>""}, "authenticity_token"=>"TntGzQ/plgGWKh66F74sDwUXCJVKrv0tYSfaOlUMiFE=", "schedule"=>{"user_id"=>[""], "event"=>"1", "team_id"=>"", "arrival_time"=>"", "time"=>"Sat, 07 Jul 2012 09:15 pm", "for"=>"", "against"=>"", "home_or_away"=>"", "location_id"=>"", "opponent_id"=>""}, "commit"=>"Create Schedule"}
Rendered user_mailer/welcome_email.html.erb (0.4ms)
Sent mail to *******@westnet.com.au (60075ms)
Completed 500 Internal Server Error in 60213ms
Timeout::Error (execution expired):
app/controllers/schedules_controller.rb:59:in `create'
app/controllers/schedules_controller.rb:56:in `create'
我的 schedule_controller 中有以下内容
def create
@schedule = Schedule.new(params[:schedule])
@user = User.find(current_user)
respond_to do |format|
if @schedule.save
UserMailer.welcome_email(@user).deliver
format.html { redirect_to(schedules_url,
:notice => "#{event_display_c(@schedule.event)} was successfully created.") }
format.json { render :json => @schedule, :status => :created, :location => @schedule }
else
format.html { render :action => "new" }
format.json { render :json => @schedule.errors, :status => :unprocessable_entity }
end
end
结尾
和我的邮件
class UserMailer < ActionMailer::Base
default :from => "notifications@**********"
def welcome_email(user)
@user = user
@url = "http://example.com/login"
mail(:to => user.email, :subject => "Welcome to My Awesome Site")
end
end