繁体   English   中英

Rails迁移问题专栏

[英]Rails migration issue column

我有简单的迁移添加列

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

为什么会发生?

护栏4

Fee.reset_column_information

解决了我的问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM