MissingPropertyException in grails -


i have problem when try show view of 1 of domains. built method sum quantities, have error , don't know how fix it. understand variable awards not exist, have value in domain. here code of method in controller gives me error.

uri /rewards/customer/show/1 class groovy.lang.missingpropertyexception message no such property: awards class: rewards.customer  around line 14 of grails-app/services/rewards/calculationsservice.groovy 11:  12: def gettotalpoints(customerinstance){ 13:     def totalawards = 0 14:     customerinstance.awards.each{ 15:         totalawards = totalawards + it.points 16:     } 17:     customerinstance.totalpoints = totalawards  around line 33 of grails-app/controllers/rewards/customercontroller.groovy 30:  31: def show(long id){ 32:     def customerinstance = customer.get(id) 33:     customerinstance = calculationsservice.gettotalpoints(customerinstance) 34:     [customerinstance: customerinstance] 35: } 36:  

controller (customercontroller.groovy)

package rewards  class customercontroller {     static scaffold = true      def calculationsservice      def show(long id){         def customerinstance = customer.get(id)         customerinstance = calculationsservice.gettotalpoints(customerinstance)         [customerinstance: customerinstance]     } 

model costumer

class customer {      string firstname     string lastname     long phone     string email     integer totalpoints     static hastmany = [awards:award, orders:onlineorder]      static constraints = {         phone()         firstname(nullable: true)         lastname(nullable: true)         email(nullable: true, email: true)         totalpoints(nullable: true)     } } 

model award

package rewards  class award {     date awarddate     string type     integer points     static belongsto = [customer:customer]      static constraints = {     } } 

services (calculationsservice.groovy)

package rewards  import grails.transaction.transactional  @transactional class calculationsservice {       def servicemethod() {      }      def gettotalpoints(customerinstance){         def totalawards = 0         customerinstance.awards.each{             totalawards = totalawards + it.points         }         customerinstance.totalpoints = totalawards         return customerinstance     } } 

you've spelled hasmany wrong in customer domain.

static hastmany = [awards:award, orders:onlineorder] 

should be

static hasmany = [awards:award, orders:onlineorder] 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -