2

I added a new attribute to my Booking model through a migration.

class AddPickupTimeEndAndPickupDetailsToBookings < ActiveRecord::Migration
  def change
    add_column :bookings, :pickup_details, :string
  end
end

I am now adding validation code:

class Booking < ActiveRecord::Base
  [...]
  validates :pickup_details, length: { maximum: 150 }

and suddenly all my Booking model specs are failing with:

Failure/Error: create(:booking)
NoMethodError:
  undefined method `pickup_details' for #<Booking:0x0000006d043e28>

Either I messed things up awfully, either I'm missing something obvious...

1 Answer 1

12

Have you run migrations for the test environment?

RAILS_ENV=test rake db:migrate
2
  • So I was missing something obvious. Thank you!
    – edhel
    Oct 13, 2014 at 7:04
  • In my case I had done some rollbacks and re-migrations and did't reset my test database. thanks!
    – VCavallo
    Aug 29, 2019 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.