Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.45 KB | None | 0 0
  1. class Owner {
  2.    static hasOne = [ owned:Owned ]
  3. }
  4.  
  5. class Owned {
  6.   Owner owner
  7. }
  8.  
  9. class OwnedController {
  10.   def save = {
  11.     def owner = Owner.findById(1)
  12.     owner.owned = new Owned()
  13.     owner.save()
  14.     redirect(controller:"owner", action:"view")
  15.   }
  16. }
  17.  
  18. class OwnerController {
  19.   def view = {
  20.     [owner:Owner.findById(1)]
  21.   }
  22. }
  23.  
  24. //owner/view.gsp
  25. owned exists: ${owner.owned != null}
  26.  
  27. //outputs owned exsits: false consistantly
Add Comment
Please, Sign In to add comment