RoR梅勒问题

时间:2012-07-07 11:37:53

标签: ruby-on-rails actionmailer

我尝试在创建活动时向活动用户发送电子邮件。虽然这样做我得到以下错误

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

1 个答案:

答案 0 :(得分:1)

看起来问题是您的电子邮件服务器配置错误。修复此问题取决于您的ISP /服务器主机,但请查看Ruby on Rails Guides以获取有关设置内容的详细信息。如果您使用GMail,还可以使用步骤配置服务器设置。