我需要使用他在表单中输入的用户数据,但不保存。
我在我的用户模型中添加了属性访问器:
attr_accessible :paypal_email, :first_name, :last_name
attr_accessor :first_name
attr_accessor :last_name
但是用户提交表单后如何使用它?我需要验证帐户详细信息,但没有保存它们,所以我需要在控制器中使用
@user.first_name and @user.last_name
我的验证操作:
def verify
@user = User.find(params[:user_id])
require 'httpclient'
require 'xmlsimple'
clnt = HTTPClient.new
header = {"X-PAYPAL-SECURITY-USERID" => "№№№№№№№№",
"X-PAYPAL-SECURITY-PASSWORD" => "333333333",
"X-PAYPAL-SECURITY-SIGNATURE" => "3333333333",
"X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT" => "XML",
"X-PAYPAL-APPLICATION-ID" => "APP-2J632856DC989803F"
}
data = {"emailAddress" => @user.paypal_email,
"firstName"=> @user.first_name,
"lastName" => @user.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
和错误:
Invalid request parameter: lastName</message><parameter>lastName
我该怎么做?