无法在 typed_store 中使用 :text
Unable to use :text in typed_store
我试过
typed_store :meta do |s|
s.string :name
s.text :instructions
end
这给我一个错误 key not found: :text
即使 :text
已列出 here
[:string, :text, :integer, :float, :time, :datetime, :date, :boolean, :decimal, :any].each do |type|
有谁知道我做错了什么? s.string
有效但 s.text
无效
您确定 gem 允许 text
作为允许的类型吗?
# 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
我试过
typed_store :meta do |s|
s.string :name
s.text :instructions
end
这给我一个错误 key not found: :text
即使 :text
已列出 here
[:string, :text, :integer, :float, :time, :datetime, :date, :boolean, :decimal, :any].each do |type|
有谁知道我做错了什么? s.string
有效但 s.text
您确定 gem 允许 text
作为允许的类型吗?
# 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