rails database array code example
Example 1: model with array rails
create_table :products do |t|
t.string :name
t.text :colors, array: true, default: []
end
Example 2: rails store array in database
class AddSubjectsToBook < ActiveRecord::Migration
def change
add_column :books, :subjects, :text, array:true, default: []
end
end