On 17 August 2010 03:35, madisonkel <[email protected]> wrote:
> I know that I can use serialize to declare hashes or arrays in a class
> that need to be used in the db. From 
> http://api.rubyonrails.org/classes/ActiveRecord/Base.html:
>
>  class User < ActiveRecord::Base
>    serialize :preferences
>  end
>
>  user = User.create(:preferences => { "background" => "black",
> "display" => large })
>
> My question is what type do you give the variable :preferences for the
> migration? In:
>
> ruby script/generate migration _add_hash_column preferences:???
>
> What is ??? -- text, string, something else?

>From the ActiveRecord docs:

"Active Record can serialize any object in text columns using YAML"

so the column type is just :text.

Chris

-- 
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