Hello,
I would like to deserialize an serialized object. So it's possible to process such as (with JSON):
>> l = Yea.create(:title => "foo bar")
=> #<Yea id: 3, title: "foo bar", created_at: "2010-07-05 21:44:54", updated_at: "2010-07-05 21:44:54">
>> j = l.to_json
=> "{\"yea\":{\"created_at\":\"2010-07-05T21:44:54Z\",\"title\":\"foo bar\",\"updated_at\":\"2010-07-05T21:44:54Z\",\"id\":3}}"
>> Yea.delete(3)
=> 1
>> a = ActiveSupport::JSON.decode(j)
=> {"yea"=>{"created_at"=>"2010-07-05T21:44:54Z", "title"=>"foo bar", "updated_at"=>"2010-07-05T21:44:54Z", "id"=>3}}
>> Yea.create(a[:yea])
=> [#<Yea id: 4, title: "foo bar", created_at: "2010-07-05 21:44:54", updated_at: "2010-07-05 21:44:54">]
But I would like to write this a little bit more generic, using some thing like:
ActiveRecord.create(a)
rather than:
Yea.create(a[:yea])
Do you know how to do so? Thank you for any help.