Closed
Description
Describe your problem here.
Annotation puts wrong default value when we use enumerize attribute.
In model annotation I have integer field with string default value for attribute state which looks strange for me.
Migration
class CreateTriggers < ActiveRecord::Migration[5.2]
def change
create_table :triggers do |t|
t.references :order, null: false, index: true
t.binary :value, null: false, limit: 128
t.integer :state, null: false, default: 0, index: true, limit: 1, unsigned: true
t.integer :ord_type, null: false, index: true, limit: 1, unsigned: true
t.timestamps
end
end
end
Model
class MyModel < ActiveRecord::Base
extend Enumerize
STATES = { pending: 0, active: 100, done: 200, cancelled: -100 }.freeze
enumerize :state, in: STATES, scope: true
end
# == Schema Information
# Schema version: 20190529142209
#
# Table name: triggers
#
# id :bigint(8) not null, primary key
# order_id :bigint(8) not null
# value :binary(128) not null
# state :integer default("pending"), unsigned, not null
# ord_type :integer unsigned, not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_triggers_on_ord_type (ord_type)
# index_triggers_on_order_id (order_id)
# index_triggers_on_state (state)
Commands
bundle exec rake annotate_models
Version
- annotate version 2.7.4
- rails version 5.2.3
- ruby version 2.6.2
Metadata
Metadata
Assignees
Labels
No labels