Ruby on Rails Multipurpose ActiveRecord columns How To


Example

In your migration

class Users < ActiveRecord::Migration[5.0]
  def change
    create_table :users do |t|
      ...
      t.text :preference
      t.text :tag
      ...
      t.timestamps
    end
  end
end

In your model

class User < ActiveRecord::Base
    serialize :preferences, Hash  
    serialize :tags, Array
end