Answers for "rails array"

1

model with array rails

create_table :products do |t|
  t.string :name
  t.text :colors, array: true, default: []
end
Posted by: Guest on July-01-2020
1

Ruby Array.new syntax

Array.new( number of indices, value of the indices ) { optional block for value of indices }

ary = Array.new    #=> []
Array.new(3)       #=> [nil, nil, nil]
Array.new(3, true) #=> [true, true, true]
Array.new(3) { Hash.new } #=> [ {}, {}, {} ]
Posted by: Guest on February-07-2020

Browse Popular Code Answers by Language