Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:35:33+00:00 2026-06-10T12:35:33+00:00

I need to verify User data before_save. I’m saving only paypal_email, and don’t save

  • 0

I need to verify User data before_save. I’m saving only paypal_email, and don’t save first and last name.

I added before_save filter in my model:

   attr_accessible :paypal_email, :first_name, :last_name
   attr_accessor :first_name
   attr_accessor :last_name

   before_save :verify

and added veify method:

   protected
 def verify

require 'httpclient'
require 'xmlsimple'

clnt = HTTPClient.new

header =  {"X-PAYPAL-SECURITY-USERID" => "1111111111",
                "X-PAYPAL-SECURITY-PASSWORD" => "111111",
               "X-PAYPAL-SECURITY-SIGNATURE" => "11111",
               "X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
               "X-PAYPAL-RESPONSE-DATA-FORMAT" => "XML",
               "X-PAYPAL-APPLICATION-ID" =>  "APP-2J632856DC989803F"
                }
 logger.info(@user.first_name)               
 data = {"emailAddress" => self.paypal_email,
       "firstName"=> self.first_name,
       "lastName" => self.last_name,
       "matchCriteria" => "NAME",         
       "requestEnvelope.errorLanguage" => "en_US"}

 uri = "https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus"
 res = clnt.post(uri, data, header)
 @xml = XmlSimple.xml_in(res.content)

  if res.status == 200
    if @xml['accountStatus']!=nil
      account_status = @xml['accountStatus'][0]
      if account_status == "VERIFIED" 
        redirect_to :back
        flash[:success] = "Your account is verified"
      else 
        redirect_to :back
        flash[:error] = res.content
      end

    else
      redirect_to :back
       flash[:error] = res.content
   end  
   else 
    flash[:error] = "Oops! Can't conntect to PayPal"
  end

 end

EDIT

    def create
     @user = User.new(params[:user])
     if @user.valid?
         @user.save
         flash[:notice] = "success"
     else
         render :new
         flash[:error] = "error"

 end

what give me error:

     undefined method `first_name' for nil:NilClass

Where is my error ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:35:34+00:00Added an answer on June 10, 2026 at 12:35 pm

    Since you’re in your model, replace @user.first_name with self.first_name or even first_name

    Other issues

    • third party service calls should live in background jobs.

    • point flash is unknown in models, it belongs to controller, as well as redirect.

    • redirect_to :back, is not that a good practice: some browsers don’t send the referrer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to verify if user have posted with XMLHttpRequest some data to PHP? This
I need to verify a procedure that has an out cursor parameter. Specifically I
I need to verify that a code generated in one class is same as
I need to verify if the args are valid file names, is this the
I need to verify that a simplified DTD is really a subset of a
I need to verify a password using reqex. I have written one and tested
I need to verify in php that a string should not start or end
I need to verify if the second word from $line_from_file is a string with
I have a need to verify the integrity of a settings file. The file
I have a string which I need to verify if it's a Country code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.