我通过迁移为我的预订模型添加了一个新属性。
class AddPickupTimeEndAndPickupDetailsToBookings < ActiveRecord::Migration
def change
add_column :bookings, :pickup_details, :string
end
end
我现在正在添加验证码:
class Booking < ActiveRecord::Base
[...]
validates :pickup_details, length: { maximum: 150 }
突然我所有的预订模型规格都失败了:
Failure/Error: create(:booking)
NoMethodError:
undefined method `pickup_details' for #<Booking:0x0000006d043e28>
要么我把事情弄得很糟糕,要么我错过了一些明显的东西......
答案 0 :(得分:9)
您是否为测试环境运行迁移?
RAILS_ENV=test rake db:migrate