When I create a table with the following SQL:

# create table foos (id SERIAL, content VARCHAR(255));

And define a class as follows:

class Foo < ActiveRecord::Base
  serialize :content, JSON
end

Creating a new instance of the class gives an error:

> f = Foo.new
NoMethodError: undefined method `read' for nil:NilClass
from 
/Users/andy/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in
 `method_missing'
 from 
/Users/andy/Code/FakePlatform/vendor/gems/Darwin/gems/json-1.4.6/lib/json/common.rb:286:in
 `load'
 from 
/Users/andy/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/base.rb:1938:in
 `block in set_serialized_attributes'

Does anyone have any ideas how to fix this?

It should work (it's such a simple case).

Cheers,


Andy

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to