У меня есть модель, которая выглядит примерно так:
class At::ModalityCombo < Base
self.table_name = 'at_modalites_at_combos'
belongs_to :at_modality, :class_name => 'At::Modality', foreign_key: :modality_id
belongs_to :at_combo, :class_name => 'At::Combo', foreign_key: :combo_id
attr_reader :modality_day
attr_writer :modality_day
end
Миграция для столбца modality_day
выглядит так:
class AddDayInModalityCombo < ActiveRecord::Migration[5.2]
def up
add_column :at_modalites_at_combos, :modality_day, :integer, default: 0
end
def down
remove_column :at_modalites_at_combos, :modality_day
end
end
Вкл. консоль rails,
abc = At::ModalityCombo.new
abc.modality_day = 4
abc
Вывод:
modality_id: nil, combo_id: nil, modality_day: 0
Почему modality_day по-прежнему равен 0?