Please help me to understand why this piece of rspec code is behaving this way. I am setting product_id to my record, and it is asserting true, but yet record.product not returning anything.
Also posted at stackoverflow: http://stackoverflow.com/questions/32414734/setting-foreign-keys-at-rails-yet-record-association-name-returning-nil
( Please don’t downvote )
Also posted at stackoverflow: http://stackoverflow.com/questions/32414734/setting-foreign-keys-at-rails-yet-record-association-name-returning-nil
( Please don’t downvote )
Check how product is defined in the tshirt model. Also check the value of product.id, it may be nil for all we know and tshirt.product_id is also nil so they’re equal.
good point but nope, they are not nil
What do the following show? puts TShirt.last.inspect puts product.inspect puts Tshirt.last.product.inspect
and copy/paste the start of t_shirt.rb showing the associations
Colin