Ruby: How to write an array to postgresql? -
this migration file:
class adddependentcolumntofeatures < activerecord::migration def change add_column :features, :dependent, :string, array: true, default: [] end end
this part of array - important field "dependent":
... display_on_detail_view"=>"1", "description"=>"", "dependent"=>["569", "571"] ...
it written on form submit per "update_attributes" (rails 3.2.13)
my problem is, in database migrate file created "string" column default length of 255 characters.
the above array looks this, after put pg-database:
--- - !binary |- nty5 - !binary |- ntcx
which not helpful test , array way larger in production mode 800 numbers instead of 2 - column length of 255 characters won't last long - there different way store array database? or doing wrong?
class adddependentcolumntofeatures < activerecord::migration def change add_column :features, :dependent, :text end end class feature < activerecord::base serialize :dependent, array end
feature.last.dependent #will return array
Comments
Post a Comment