代码之家  ›  专栏  ›  技术社区  ›  jdog

为什么Ruby会在ArgumentError中出错(未知关键字:api\u key)

  •  0
  • jdog  · 技术社区  · 5 年前

    刚刚升级到:

    ruby '2.4.2'
    gem 'rails', '5.0'
    

    ArgumentError (unknown keyword: api_key):
    
    app/models/user.rb:225:in `new'
    app/models/user.rb:225:in `send_approval_code'
    app/models/user.rb:292:in `create_new'
    app/controllers/ms_controller.rb:249:in `create_dude'
    
    
    def create_dude
    attributes = {}
    if params[:email].blank?
      render :js => "error('email2', 'required');"
      return
    elsif params[:phone].blank?
      render :js => "error('phone2', 'required');"
      return
    elsif User.where(:email => params[:email]).count > 0
      render :js => "error('email2', 'already exists');"
      return
    elsif !params[:password].blank?
      if params[:password].length < 6
        render :js => "error('password2', 'must be at least 6 characters');"
        return
      elsif params[:password_confirmation].blank?
        render :js => "error('password_confirmation2', 'required');"
        return
      elsif params[:password] != params[:password_confirmation]
        render :js => "error('password_confirmation2', 'does not match');"
        return
      else
        attributes[:password] = params[:password]
      end
    end
    attributes[:email] = params[:email] if params[:email]
    attributes[:password] = params[:password] if params[:password]
    attributes[:password_confirmation] = params[:password] if params[:password]
    attributes[:first_name] = params[:first_name] if params[:first_name]
    attributes[:last_name] = params[:last_name] if params[:last_name]
    attributes[:last_4_soc] = params[:last_4_soc] if params[:last_4_soc]
    attributes[:drivers_license] = params[:drivers_license] if params[:drivers_license]
    attributes[:phone] = params[:phone] if params[:phone]
    attributes[:type] = User::PLOTTER
    attributes[:emrt_id] = @emrt.id.to_s
    attributes[:approved] = true
    attributes[:verified_phone_number] = false
    if @ems.type == Nms::MURSE
      attributes[:stand_alone_type] = params[:type]
    end
    r = User.create_new(attributes)
    if r[:status] == 'OK'
      if @ems.type == Nms::MURSE
        u = User.where(:email => params[:email]).first
        u.create_stand_alone_amb(params[:plate_number]) if u
        u.stand_alone_amb.update_attributes(:icon_color => params[:color])
      end
      render :js => "location.reload();"
    else
      render :js => "error('email2', 'error. please try again');"
    end
    

    结束

    client = SendGrid::Client.new(api_key: SENDGRID_PROD_KEY)
    

    更新:

        ArgumentError (wrong number of arguments (given 1, expected 0)):
    
        app/models/user.rb:228:in `new'
        app/models/user.rb:228:in `send_approval_code'
        app/models/user.rb:292:in `create_new'
        app/controllers/ms_controller.rb:249:in `create_dude'
    
    0 回复  |  直到 5 年前