activerecord-typedstore icon indicating copy to clipboard operation
activerecord-typedstore copied to clipboard

Attempting to assign a default to an array type does not work.

Open lundie opened this issue 5 years ago • 2 comments

Hi,

I am attempting the following:

class Member < ApplicationRecord

#  application_layout                :jsonb

typed_store :application_layout do |s|
    s.string :tabs, default: ["company_information", "company_history", "company_contacts", "company_references", "banking_information"], array:true, null: false
   s.string :page_title_en, default: "My Online Form"
end

Then running in the console:

m = Member.new
m.tabs
(which returns a blank array [])
m.pate_title_en 
(returns the title "My Online Form").

I can set the value of the array after the fact and it works.

Is there a way to default the values of the array?

Thanks :)

lundie avatar Apr 03 '20 14:04 lundie

Weird, this should work. Sounds like a bug.

casperisfine avatar Apr 03 '20 14:04 casperisfine

Just ran into this bug too. It ignores my default: and initializes with an empty array instead.

gilbert avatar May 18 '20 01:05 gilbert