Rails 4 - 设计在开发模式下工作,但不在生产模式下工作

时间:2016-06-26 00:28:17

标签: ruby-on-rails ruby devise omniauth dev-to-production

我的设计/ omniauth在我的开发模式下工作(在设置它3。5年后)。

当我推向生产并尝试登录时,出现以下错误:

app/models/user.rb:159:in `find_for_oauth'
2016-06-26T00:24:21.173282+00:00 app[web.1]: 
2016-06-26T00:24:21.173264+00:00 app[web.1]: 
2016-06-26T00:24:21.173279+00:00 app[web.1]: Net::SMTPFatalError (553-5.1.2 The recipient address <change@me-114727432687651490566-google_oauth2.c

我的用户模型的第159行有:

    user.save!

该行是方法的最后一步:

 def self.find_for_oauth(auth, signed_in_resource = nil)
    # Get the identity and user if they exist
    identity = Identity.find_for_oauth(auth)

    # If a signed_in_resource is provided it always overrides the existing user
    # to prevent the identity being locked with accidentally created accounts.
    # Note that this may leave zombie accounts (with no associated identity) which
    # can be cleaned up at a later date.
    user = signed_in_resource ? signed_in_resource : identity.user

    # p '11111'

    # Create the user if needed
    if user.nil?
      # p 22222
      # Get the existing user by email if the provider gives us a verified email.
      # If no verified email was provided we assign a temporary email and ask the
      # user to verify it on the next step via UsersController.finish_signup
      email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email)
      email = auth.info.email if email_is_verified # take out this if stmt for chin yi's solution
      user = User.where(:email => email).first if email

      # Create the user if it's a new registration
      if user.nil?
        # p 33333
        user = User.new(
          # at least one problem with this is that each provider uses different terms to desribe first name/last name/email. See notes on linkedin above
          first_name: auth.info.first_name,
          last_name: auth.info.last_name,
          email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
          #username: auth.info.nickname || auth.uid,
          password: Devise.friendly_token[0,20])
# fallback for name fields - add nickname to user table
        # debugger

        if email_is_verified
           user.skip_confirmation!
        end
        # user.skip_confirmation! 

        user.save!
      end
    end

    # Associate the identity with the user if needed
    if identity.user != user
      identity.user = user
      identity.save!
    end
    user
  end

任何人都可以看到我需要做些什么来使其在生产模式下工作?

0 个答案:

没有答案