1
我想知道什麼最好的解決方案可以使用ActiveRecord
的enum與Ember數據中的DS.model一起。定義在餘燼上的枚舉DS.Model
例如,如果我在Rails的模型有一個枚舉:
# in the migration
t.integer :status, default: 0
# in the model
enum status: [:draft, :in_wizard, :published, :archived]
我首先想到的是對DS.model定義一個整數類型:
status: DS.attr('number')
但是,使用灰燼Data和ActiveModel Serializer,串行器將這些枚舉序列化爲字符串,所以json最終以:
{status: 'draft'}
所以這應該是DS.attr('string')
還是有一種方法來指定枚舉數據中的枚舉?