Unable to use :text in typed_store

Viewed 57

I tried doing

  typed_store :meta do |s|
    s.string :name
    s.text   :instructions
  end

which gives me an error key not found: :text even though :text is listed here

[:string, :text, :integer, :float, :time, :datetime, :date, :boolean, :decimal, :any].each do |type|

does anyone know what I'm doing wrong? s.string works but not s.text

1 Answers

Are you sure the gem allow text as permitted type ?

# lib/active_record/typed_store/field.rb#L38

TYPES = {
      boolean: ::ActiveRecord::Type::Boolean,
      integer: ::ActiveRecord::Type::Integer,
      string: ::ActiveRecord::Type::String,
      float: ::ActiveRecord::Type::Float,
      date: ::ActiveRecord::Type::Date,
      time: ::ActiveRecord::Type::Time,
      datetime: ::ActiveRecord::Type::DateTime,
      decimal: ::ActiveRecord::Type::Decimal,
      any: ::ActiveRecord::Type::Value,
    }

    def lookup_type(type, options)
      TYPES.fetch(type).new(**options)
    end
Related