Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FactoryGirl not aware of new column

Hi I am using FactoryGirl 4.9.0 w/ Rails 4.2.11. I added a boolean column to a model called Query like so:

class AddSetLatestResultToQueries < ActiveRecord::Migration
  def change
    add_column :queries, :latest_result_s3_url_flag, :boolean, null: false, default: false
  end
end

This flag works fine and the app itself works fine but when it comes to rspec, FactoryGirl seems to be having trouble acknowledging this new column.

I tried to add it to the factory model like this:

FactoryGirl.define do
  factory :query do
    latest_result_s3_url_flag false
    title 'some title'
    latest_body 'SELECT TIMEOFDAY();'

 ... etc ...

end

But when I run rpsec spec, I see this error:

      NoMethodError:
        undefined method `latest_result_s3_url_flag=' for #<Query:0x00007ff6f9108428>
like image 201
hiroprotagonist Avatar asked Nov 18 '25 04:11

hiroprotagonist


1 Answers

Just run this:

RAILS_ENV=test rake db:migrate
like image 94
NeverBe Avatar answered Nov 19 '25 19:11

NeverBe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!