服务器重新启动GEM问题

时间:2014-01-17 10:21:25

标签: ruby-on-rails ubuntu gem

出于某种原因,每次我重新启动服务器时,我的应用程序中都有一个功能(与邮件功能无关)会触发一条错误消息:

At least one recipient (To, Cc or Bcc) is required to send a message vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:104:in发送!'`这导致我的ruby / rails应用程序出错。

知道如何一劳永逸地停止这种行为吗?

谢谢!

以下是完整的跟踪

-------------------------------
Request:
-------------------------------

 * URL       : https://www.xyz.com/cactus/new
 * IP address: xyz
 * Parameters: {"action"=>"new", "controller"=>"cactus"}
 * Rails root: /xyz


-------------------------------
Session:
-------------------------------

 * session id: [FILTERED]
 * data: {"session_id"=>"17cd11ecb9aa08e0c1dc3a3742ed75eb",
  "beta"=>true,
  "_csrf_token"=>"H1G4p8Fy2qfYq/lj0nECghOObBXox0WYLTlgKS2zFLA=",
  "warden.user.user.key"=>["User", [2], "$2a$10$C8skQV0ddKelZ8jqqBlr9O"]}

-------------------------------
Environment:
-------------------------------

 * DOCUMENT_ROOT                                  : xyz
 * HTTPS                                          : on
 * HTTP_ACCEPT                                    : application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
 * HTTP_ACCEPT_ENCODING                           : gzip, deflate
 * HTTP_ACCEPT_LANGUAGE                           : en-us
 * HTTP_AUTHORIZATION                             : Basic YmV0YTpHZjlaaFUmUzs2LUZk
 * HTTP_CONNECTION                                : keep-alive
 * HTTP_COOKIE                                    : xyz
 * HTTP_HOST                                      : xyz
 * HTTP_REFERER                                   : https://xyz
 * ORIGINAL_FULLPATH                              : /cactus/new
 * PASSENGER_APP_TYPE                             : rack
 * PASSENGER_CONNECT_PASSWORD                     : [FILTERED]
 * PASSENGER_DEBUGGER                             : false
 * PASSENGER_ENV                                  : production
 * PASSENGER_FRIENDLY_ERROR_PAGES                 : true
 * PASSENGER_GROUP                                : 
 * PASSENGER_MAX_PRELOADER_IDLE_TIME              : -1
 * PASSENGER_MAX_REQUESTS                         : 0
 * PASSENGER_MIN_INSTANCES                        : 1
 * PASSENGER_RUBY                                 : /usr/local/rvm/wrappers/ruby-1.9.3-p448/ruby
 * PASSENGER_SHOW_VERSION_IN_HEADER               : true
 * PASSENGER_SPAWN_METHOD                         : smart
 * PASSENGER_USER                                 : 
 * PATH_INFO                                      :  /cactus/new
 * QUERY_STRING                                   : 

 gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
 vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
 vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
 vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
 vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in `call_app'
 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/logger.rb:16:in `call'
 vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in `call'
 vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
 vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
 vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:479:in `call'
 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:220:in `call'
 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
 /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.10/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
 /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.10/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
 /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.10/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
 /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.10/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'

这是一段代码:

class CactusController < ApplicationController
  load_and_authorize_resource
  before_filter :authenticate_user!, :only => [:follow]
  before_filter :check_email_verified, :only => [:edit]
  respond_to :html, :xml

  def index
    @keyword = " "
    if params[:search].present?
      @main_search_value = params[:search]
      @keyword = @keyword + params[:search]
    end
    @keyword = @keyword + params[:category_name] if params[:category_name].present?
    @keyword = @keyword + params[:city_name] if params[:city_name].present?
    @keyword = @keyword + params[:country_name] if params[:country_name].present?
    @cactus = Cactus.perform_search(params[:search], params[:category_name], params[:city_name], params[:country_name])
  end


  end

  def show

    if user_signed_in?
      return redirect_to :root, :alert => "Invalid cactus" unless  @cactus.suspended? or @cactus.unsuccessfull? or @cactus.activated? or @cactus.successfuly_completed? or @cactus.cancelled? or current_user.id == @cactus.user_id or current_user.has_role? :admin or current_user.has_role? :subadmin
      respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @cactus }
      end
    else
      return redirect_to :root, :alert => "Invalid cactus" if  @cactus.incomplete? or @cactus.pending?
      respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @cactus }
      end
    end
  end

  def new
    if user_signed_in?
      @cactus = Cactus.new(:state => 'basics', :status => "incomplete")
      @cactus.user = current_user
      @cactus.save(:validate => false)
      if !@cactus.is_spam?
        UserMailer.new_cactus_alert(@cactus).deliver
        AdminMailer.new_cactus_alert(@cactus).deliver
        redirect_to edit_cactus_path(@cactus)
      else
        redirect_to :root
      end
    else
      flash[:alert] = t('alerts.tips')
      return redirect_to new_user_session_path
    end
  end

  def edit
    return redirect_to :back, :alert => "You cannot edit this cactus. This Cactus has successfully been completed" if @cactus.successfuly_completed?
    return redirect_to :back, :alert => "You cannot edit this cactus as this Cactus is under review" if @cactus.pending? and !current_user.has_role? :admin and !current_user.has_role? :subadmin
    if @cactus.activated? and params[:current_step].present? and !current_user.has_role? :admin and !current_user.has_role? :subadmin
      if params[:current_step] != "YOUPI"
        if params[:current_step] == "preview"
          return redirect_to :back, :alert => "The changes have been submitted to XYC for review"
        end
        return redirect_to :back, :alert => t('alerts.edit')
      end
    elsif @cactus.activated? and !current_user.has_role? :admin and !current_user.has_role? :subadmin
      return redirect_to :back, :alert => t('alerts.edit')
    end
    if @cactus.deleted? and !current_user.has_role? :admin and !current_user.has_role? :subadmin
      return redirect_to :root, :notice => t('alerts.edit2')
    end
    @cactus = Cactus.find(params[:id])
    if params[:current_step].present?
      @cactus.state = params[:current_step]
      @cactus.save(:validate => false)
    end
    if @cactus.launched? && @cactus.final?
      @cactus.state = "basics"
      @cactus.save
    end
  end

  def create
    respond_to do |format|
      if @cactus.save(:validate => false)
        flash[:notice] = t('alerts.create')
        format.html { redirect_to(edit_cactus_path(@cactus)) }
      else
        format.html { render :action => "new" }
      end
    end
  end

  def update
    respond_to do |format|
      YOUPI_present = params.evaluate(:cactus, :YOUPI_attributes).present?
      if YOUPI_present
        params[:cactus][:YOUPI_attributes].each do |k, AVC|
          correct_AVC_attrs_delivered_at(AVC)
        end
      end

      if YOUPI_present
        count_to_be_deleted = params[:cactus][:YOUPI_attributes].collect { |i, r| r["_destroy"].to_i }.sum
        count_to_be_created = params[:cactus][:YOUPI_attributes].count { |i, r| i.start_with? 'new' }
      else
        count_to_be_deleted = 0
        count_to_be_created = 0
      end

        if params[:save_AVC]
          if @cactus.errors.present?
            format.html { render action: "edit" }
          end
        end
        if @cactus.details? and params[:cactus][:funding_closed_at].present?
          if current_user.has_role? :admin or current_user.has_role? :subadmin
            @cactus.funding_closed_at = params[:cactus][:funding_closed_at]
            if @cactus.save
              @cactus.deadline = @cactus.cactus_deadline
            end
          else
            if @cactus.save
              @cactus.deadline = nil
            end
          end
          @cactus.save
        end
        if @cactus.approved? and !@cactus.preview?
          @cactus.status = "incomplete"
          if @cactus.update_attributes(params[:cactus])
            @cactus.spam = Akismet.spam?({
                                              :user_ip => request.remote_ip,
                                              :user_agent => request.env['HTTP_USER_AGENT'],
                                              :referrer => request.env['HTTP_REFERER'],
                                              :permalink => root_path(),
                                              :comment_type => 'comment',
                                              :comment_author => @cactus.user.name,
                                              :comment_author_email => @cactus.user.email,
                                              :comment_author_url => 'http://www.doe.com',
                                              :comment_content => [@cactus.description, 

        if params[:save_button]
          @cactus.attributes = params[:cactus]
          if @cactus.approved?
            @cactus.status = "incomplete"
            if @cactus.save(:validate => false)
              @cactus.spam = Akismet.spam?({
                                                :user_ip => request.remote_ip,
                                                :user_agent => request.env['HTTP_USER_AGENT'],
                                                :referrer => request.env['HTTP_REFERER'],
                                                :permalink => root_path(),
                                                :comment_type => 'comment',
                                                :comment_author => @cactus.user.name,
                                                :comment_author_email => @cactus.user.email,
                                                :comment_author_url => 'http://www.doe.com',
                                                :comment_content => [@cactus.description, @cactus.title, @cactus.tagline].join(' ')}, request)
              @cactus.save(:validate => false)
              return redirect_to :back, :notice => "Your Cactus has been saved and You have to Re-submit it for approval"
            end
          else
            if @cactus.save(:validate => false)
              if (@cactus.photo_file_size.to_i > 2000000)
                @cactus.photo = nil
                @cactus.save(:validate => false)
              end
              if @cactus.activated?
                return redirect_to :back, :notice => "The changes have been submitted to XYC for review"
              end
              return redirect_to :back, :notice => t('alerts.save_button')
            end
          end
        end

        if params[:back_button]
          @cactus.previous_step
          format.html { redirect_to edit_cactus_path(@cactus) }
        elsif @cactus.launched? && !@cactus.preview?
          if @cactus.update_attributes(params[:cactus])
            @cactus.spam = Akismet.spam?({
                                              :user_ip => request.remote_ip,
                                              :user_agent => request.env['HTTP_USER_AGENT'],
                                              :referrer => request.env['HTTP_REFERER'],
                                              :permalink => root_path(),
                                              :comment_type => 'comment',
                                              :comment_author => @cactus.user.name,
                                              :comment_author_email => @cactus.user.email,
                                              :comment_author_url => 'http://www.doe.com',
                                              :comment_content => [@cactus.description, @cactus.title, @cactus.tagline].join(' ')}, request)
            @cactus.save(:validate => false)
            @cactus.next_step(current_user)
            format.html { redirect_to edit_cactus_path(@cactus) }
          else
            @cactus.photo = nil if @cactus.photo_file_size_changed?
            flash[:alert] = @cactus.errors.full_messages.to_sentence(sentence_opts)
            format.html { render action: "edit" }
          end
        else
          if @cactus.preview?
            return redirect_to edit_cactus_path(@cactus, :current_step => "YOUPI"), :alert => "Add at least one AVC to complete the cactus" if @cactus.YOUPI.blank?
            return redirect_to admin_cactus_path if (current_user.has_role? :admin or current_user.has_role? :subadmin) && current_user.id != @cactus.user.id
            if @cactus.complete?
              if !@cactus.per_year_cactus?
                @cactus.status = "incomplete"
                @cactus.state = 'preview'
                @cactus.save(:validate => false)
                flash[:alert] = "You cannot submit more than 4 cactus in one year"
                return redirect_to edit_cactus_path(@cactus)
              end
              if !@cactus.can_submit?
                @cactus.status = "incomplete"
                @cactus.state = 'preview'
                @cactus.save(:validate => false)
                flash[:alert] = "You cannot submit more than one cactus at a time"
                return redirect_to edit_cactus_path(@cactus)
              end
              @cactus.status = "pending"
              @cactus.save
              AdminMailer.send_approval_request(@cactus).deliver
              return redirect_to admin_cactus_path if current_user.has_role? :admin or current_user.has_role? :subadmin
              flash[:notice] = t('alerts.launched_success')
              format.html { redirect_to thank_you_cactus_path }
            else
              if @cactus.user.email_verified? && !@cactus.contact_email_verified?
                format.html { redirect_to edit_cactus_path(@cactus) }
              else
                format.html { redirect_to edit_cactus_path(@cactus), :notice => t('alerts.email_not_verified') }
              end
            end
          else
            if @cactus.update_attributes(params[:cactus])
              @cactus.spam = Akismet.spam?({
                                                :user_ip => request.remote_ip,
                                                :user_agent => request.env['HTTP_USER_AGENT'],
                                                :referrer => request.env['HTTP_REFERER'],
                                                :permalink => root_path(),
                                                :comment_type => 'comment',
                                                :comment_author => @cactus.user.name,
                                                :comment_author_email => @cactus.user.email,
                                                :comment_author_url => 'http://www.doe.com',
                                                :comment_content => [@cactus.description, @cactus.title, @cactus.tagline].join(' ')}, request)
              @cactus.save(:validate => false)
              @cactus.next_step(current_user)
              @cactus.set_max_step
              @cactus.save(:validate => false)
              if @cactus.activated?
                AdminMailer.AVC_change_notification(@cactus).deliver if @cactus.YOUPI_changed
                format.html { redirect_to cactus_path(@cactus), :alert => "The changes have been submitted to XYC for review" }
              else
                format.html { redirect_to edit_cactus_path(@cactus) }
              end
            else
              @cactus.photo = nil if @cactus.photo_file_size_changed?
              flash[:alert] = @cactus.errors.full_messages.to_sentence(sentence_opts)
              format.html { render action: "edit" }
            end
          end
        end
      end
    end
  end



@cactus.status = "cancelled"
      if @cactus.save(:validate => false)
        UserMailer.cancelled_cactus_notification(@cactus, @cactus.user.email).deliver
        UserMailer.cancelled_cactus_notification(@cactus, @cactus.contact_email).deliver

    end
    redirect_to :back
  end

  def suspend_cactus
    return redirect_to :back, :alert => 'You cannot suspend any cactus. For permissions please contact XYC admin.' unless current_user.can_suspend_cactus?
    return redirect_to :back, :alert => 'You cannot suspend this cactus. Because this cactus has been reached to its deadline.' if @cactus.remaining_days.to_i <= 0
    if @cactus.sponsored_cactus.present?
      @cactus.sponsored_cactus.where(:status => "approved").each do |sponsor|
        @cactus.cancel_POI(sponsor, @cactus)
        sponsor.status="cancelled"
        sponsor.save(:validate => false)
        UserMailer.cancelled_cactus_POI_notification(@cactus, sponsor.user).deliver
      end
    end
    @cactus.status = 'suspended'
    UserMailer.suspended_cactus_notification(@cactus, @cactus.user.email).deliver
    UserMailer.suspended_cactus_notification(@cactus, @cactus.contact_email).deliver
    @cactus.save(:validate => false)
    flash[:notice] = 'Cactus has been suspended.'
    redirect_to :back
  end

  def enable_cactus
    return redirect_to :back, :alert => 'You cannot enable any cactus. For permissions please contact XYC admin.' unless current_user.can_suspend_cactus?
    @cactus.status = 'incomplete'
    @cactus.save(:validate => false)
    flash[:notice] = 'Cactus has been enabled.'
    redirect_to :back
  end

  def verify_request
    if (params[:email].present?)
      @cactus.contact_email = params[:email].to_s
      @cactus.generate_verification_code
      UserMailer.contact_email(@cactus).deliver
      flash[:notice] = 'Verification email has been sent. Please check your email.'
    else
      flash[:alert] = 'Contact email field is empty.'
    end
    render :layout => "naked"
  end

0 个答案:

没有答案