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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -