我试图在ActiveRecord模型中序列化一个简单的属性,而Rails 2.3.4不喜欢它.
- class Shopper
- serialize :tags
- end
- >> a = Shopper.new
- => <#Shopper...>
- >>a.tags = ['aoeu','stnh']
- => ['aoeu','snth']
- >> a.save
- => TypeError: class or module required
有人知道我失踪了吗?
解决方法
Arf …我以为我可以一次序列化两个属性,但事实并非如此:
- serialize :tags,:garments # this is wrong
第二个参数应该是序列化对象的类,所以我必须这样做:
- serialize :tags
- serialize :garments
bumsicle.