1

イベントが作成されたときにアクティブユーザーに電子メールを送信しようとしています。そうするとき、私は次のエラーが発生しますが

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
4

1 に答える 1

1

問題はメールサーバーの設定ミスのようです。これを修正するかどうかはISP/サーバーホストによって異なりますが、設定内容の詳細については、RubyonRailsガイドを確認してください。Gmailを使用している場合は、サーバー設定を構成する手順もあります。

于 2012-07-07T18:10:51.343 に答える