Summary.new is expecting to receive a hash, which isn't what you're
giving it.

i.e.:
summary = Summary.new( :summary_data => { "name"=>"Administator",
"login"=>"admin" } )

summary.save!

Summary.last.summary_data
=> {"name"=>"Administrator", "login"=>"admin"}

On Feb 14, 5:29 am, phil <[email protected]> wrote:
> Hi.
> I want to serialize out an object to the database. But I am getting an
> integer value in the column when I expect to see some yaml!
>
> migration:
> class CreateSummaries < ActiveRecord::Migration
>   def self.up
>     create_table :summaries do |t|
>        t.text :summary_data
>       t.timestamps
>     end
>   end
> end
>
> class:
> class Summary < ActiveRecord::Base
>   serialize :summary_data
> end
>
> example:
> summary = Summary.new(:summary_data => User.first)
> => #<Summary id: nil, fss_player_id: nil, stats_type: nil, scope: nil,
> summary_data: #<User id: 4, login: "LoginName", email: "[email protected]",
> crypted_password: "cbc8411974ad085f608b6e0a05dd608e7577de19", salt:
> "ddc4528beea65095b7f5619912a6ca0681d0c10e", created_at: "2008-09-12
> 18:43:19", updated_at: "2009-02-05 04:20:58", remember_token: nil,
> remember_token_expires_at: nil, pw_reset_code: nil, role:
> "commissioner", sign_up_code:
> "44e11a23be5b7833bf73d479a05166c0e0377c56", reset_password_code_until:
> nil, permalink: "fname", name: "FName", street: nil, city: nil,
> province: nil, postcode: nil, country: nil, home_phone: nil,
> mobile_phone: nil, display_name: "FName", display_teams: true,
> website: nil, occupation: nil, interests: nil, favourite_teams: nil,
> anonymous_contact: false>, created_at: nil, updated_at: nil>>> summary.save!
> => true
> >> Summary.first.summary_data
>
> => 4
>
> What am I doing wrong?
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to