when running my rspec test I am getting an error very similar to the one in this post, but the author's solution is not working for me. The error:
Mysql2::Error: Field 'target_id' doesn't have a default value: INSERT INTO `illegal_links` (`url`, `status`, `time_found`, `track_id`, `user_id`, `created_at`, `updated_at`) VALUES ('http://www.whatever.com', 'new', '2013-12-19 17:25:52.000000', 3212, 6980, '2017-09-27 15:40:38.121788', '2017-09-27 15:40:38.121788')
The 'illegal link' factory calls the target factory along with two others, but target_id is the only one that throws an error:
factory :illegal_link do
url "http://www.whatever.com"
status "new"
time_found "2013-12-19 17:25:52"
url_type "file"
track
target
user
What I really don't understand is that removing the call to the target factory and instead using 'target_id 1' gets the same error. Creating 'targets' from the console each get a new id, so it is not a missing auto increment in mysql.
I'm running rails 4.2.0, ruby 2.3.0, rspec-rails 3.6.0, factory_girl 4.8.0, and mysql2 0.3.21
Any ideas would be appreciated, thanks.
Edit: here is the schema for the target_id on the illegal_links tables:
t.integer "target_id", limit: 4, null: false
add_index "illegal_links", ["target_id"], name: "target_id", using: :btree