Skip to content
This repository
Browse code

Pass contact id when redirect

Handle no contact ID if studentId passed.
  • Loading branch information...
commit b8943689474c0e905accb548d3f970d2d10caf63 1 parent 2abaf46
Nathan Neff authored
1  DEVELOPER_NOTES.markdown
Source Rendered
... ... @@ -1,3 +1,4 @@
  1 +Foo.
1 2 # Developer Notes
2 3
3 4 Enrollio requires Grails 1.2.
14 grails-app/controllers/org/bworks/bworksdb/ContactController.groovy
@@ -29,10 +29,18 @@ class ContactController {
29 29 }
30 30
31 31 def show = {
32   - def studentInstance = Student.get( params.studentId )
33   - def contactInstance = Contact.get( params.id ) ?: studentInstance?.contact
  32 + def studentInstance
  33 + def contactInstance
34 34
35   - if(!contactInstance && !studentInstance) {
  35 + if (params.studentId) {
  36 + studentInstance = Student.get( params.studentId )
  37 + contactInstance = studentInstance.contact
  38 + }
  39 + else {
  40 + contactInstance = Contact.get(params.id)
  41 + }
  42 +
  43 + if(!contactInstance) {
36 44 flash.message = "Contact not found with id ${params.id}"
37 45 redirect(action:list)
38 46 }
4 grails-app/controllers/org/bworks/bworksdb/StudentController.groovy
@@ -117,7 +117,9 @@ class StudentController {
117 117 signupDates)
118 118 studentInstance.save()
119 119 flash.message = "Student ${studentInstance} updated"
120   - redirect(controller:'contact', action:'show', params:[studentId:studentInstance.id])
  120 + redirect(controller:'contact', action:'show',
  121 + id: studentInstance.contact.id,
  122 + params:[studentId:studentInstance.id])
121 123 }
122 124 else {
123 125 render(view:'edit',model:[studentInstance:studentInstance])

0 comments on commit b894368

Please sign in to comment.
Something went wrong with that request. Please try again.