Rails迁移问题专栏

时间:2016-12-14 11:29:15

标签: ruby-on-rails postgresql psql

我有添加列的简单迁移

class AddSeatGroupForFee < ActiveRecord::Migration
  def up
    add_column :fees, :seat_group_id, :integer
  end
end

我的Fee型号

belongs_to :seat_group

我的SeatGroup

has_many :fees

当我想在下次迁移中使用此列时 我没有这个专栏

当我停在binding.pry

seat_group_id

应该是礼物

=> Fee(id: integer, code: string, created_at: datetime, updated_at: datetime)

Fee此处没有seat_group_id

world_business = SeatGroup.create({name: '(name)', airline_code: 'code'})
world_business.fees.where(code: 'W-BUSINESS') => error here

为什么会这样?

rails 4

1 个答案:

答案 0 :(得分:0)

Fee.reset_column_information

解决了我的问题

相关问题