Rails 3序列化问题 [英] Rails 3 Serialization issue

查看:71
本文介绍了Rails 3序列化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与ror 2.3.x兼容的应用程序。我在通过序列化升级到Rails 3时遇到了麻烦。



代码如下:

  class PaymentTransaction< ActiveRecord :: Base 
serialize:response
end

该响应应该包含ActiveMerchant :: Billing :: Response。使用rails 3出于某种原因将其另存为字符串。

  => #< PaymentTransaction ID:11,order_id:无,金额:nil,模式:nil,payment_profile_id:无,响应:#< ActiveMerchant :: Billing :: Response:0x1051aec98>,created_at: 2010-11-07 04:06:03,updated_at: 2010-11-07 04:24:58,结果:待处理,收款人:nil,login_id:nil,transaction_key:nil> 

我在其他任何有关升级的博客中都没有关于序列化的记录。有什么想法吗?

解决方案

rails 3发生了很小的变化,其效果如下: https://github.com/rails/rails/commit/c1d73270717f30498f8f4d55d6695509107c2834

$ p>这里有两个有关序列化的不错的博客文章:




I have an application that was working fine with ror 2.3.x. I am having trouble upgrading to Rails 3 with serialization.

The code looks like this

class PaymentTransaction < ActiveRecord::Base
  serialize :response
end

The response is supposed to contain the ActiveMerchant::Billing::Response. With rails 3 for some reason its being save as string.

=> #<PaymentTransaction id: 11, order_id: nil, amount: nil, mode: nil, payment_profile_id: nil, response: "#<ActiveMerchant::Billing::Response:0x1051aec98>", created_at: "2010-11-07 04:06:03", updated_at: "2010-11-07 04:24:58", result: "pending", payee: nil, login_id: nil, transaction_key: nil>

I didn't any notes on serialization in any other blogs talking about upgrade. Any thoughts?

解决方案

There was a small change in rails 3 which have an effect: https://github.com/rails/rails/commit/c1d73270717f30498f8f4d55d6695509107c2834

There are two good blog posts about serialization here:

这篇关于Rails 3序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆