Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. class A < ActiveRecord::Base
  2. belongs_to :b
  3. end
  4.  
  5. class B < ActiveRecord::Base
  6. has_many :as
  7. end
  8.  
  9. b = B.create
  10. B.transaction do
  11. b.as.create!
  12. raise ActiveRecord::Rollback
  13. End
  14. b.save #=> ActiveRecord::StatementInvalid(“Mysql2::Error: Field ‘b_id' doesn't have a default value: INSERT INTO `as` VALUES ()”)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement