Guest User

Untitled

a guest
Jun 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. Users model
  2.  
  3. Users belongs_to :account
  4.  
  5. and account has_many :users
  6.  
  7. if self.account_id.nil?
  8. #This Works
  9. newaccount=Account.create(:name=>self.name)
  10. self.account_id=newaccount.id
  11. self.save
  12.  
  13. # This fails with a reference to a nil object
  14. #raise self.inspect
  15. #self.account.create(:name=>self.name)
  16. end
  17.  
  18. I checked self and name is set
  19. so why the crash
Add Comment
Please, Sign In to add comment