Note that there are some explanatory texts on larger screens.

plurals
  1. PONo signature of method is applicable for argument types: () values: []Possible solutions:(java.lang.Object), (java.lang.Object)
    primarykey
    data
    text
    <p>I have a script <code>User.groovy</code> and <code>UserController.groovy</code>. When I run it, I'm getting </p> <pre><code>Caught: No signature of method: com.vasco.gs.User.addToUserRoles() is applicable for argument types: (com.vasco.gs.Role) values: [nurse] Possible solutions: addToUserRoles(java.lang.Object), addToUserRoles(java.lang.Object), getUserRoles() </code></pre> <p><strong>My domain class</strong></p> <pre><code>package com.vasco.gs import com.vasco.gs.audit.UserAudit class User { static constraints = { userName blank: false,size:2..25, unique: true firstName blank:false, size:2..60,matches:"[a-zA-Z1-9_]+" lastName blank:false, size:2..60,matches:"[a-zA-Z1-9_]+" middleName nullable:false, blank:false, size:2..60,matches:"[a-zA-Z1-9_]+" gender blank : true, nullable:true emailId blank : false mobileNumber blank : true, nullable:true password nullable: false,blank: false,size:2..256,password:true confirmPassword nullable: true, blank: false, size:2..256 activeStatus inList:['Y', 'N'] } String userName String password String confirmPassword String firstName String lastName String middleName String emailId String mobileNumber Gender gender String activeStatus = 'Y' static hasMany = [userRoles:UserRole, userLocations: UserLocation] static transients = [ 'confirmPassword', 'activeUsers' ] static List getActiveUsers(){ return User.findAllByActiveStatus('Y') } def beforeInsert() { password = password.encodeAsSHA() } def activate(){ this.activeStatus = 'Y' } def inactivate(){ this.activeStatus = 'N' } def roles() { return userRoles.collect { it.role } } def locations() { return userLocations.collect { it.location } } List addToUserRoles(role){ UserRole.link this, role return roles() } List removeFromUserRoles(role){ UserRole.unLink this, role return roles() } List addToUserLocations(location){ UserLocation.link this, location return locations() } List removeFromUserLocations(location){ UserLocation.unLink this, location return locations() } String toString() { "$firstName" } } </code></pre> <p><strong>My Controller</strong></p> <pre><code>class UserController { static allowedMethods = [save: "POST", update: "POST", delete: "POST"] def UserService def index() { redirect(action: "list", params: params) } def list(Integer max) { params.max = Math.max(max ?: User.count(), 1) [userInstanceList: User.list(params), userInstanceTotal: User.count()] } def create() { [roleList: Role.list(),locationList: Location.list(),userInstance: new User(params)] } def save() { def userInstance = new User(params) def userRole = params.userRoles userRole.each { def userrole = Role.get(it) println userrole def userRoles = userInstance.addToUserRoles(userrole) } if(UserService.validatePassword(userInstance,params.confirmPassword)){ if (!userInstance.save(flush: true)) { render(view: "create", model: [userInstance: userInstance, userRoles:userRoles]) return } flash.message = message(code: 'default.created.message', args: [ message(code: 'user.label', default: 'User'), userInstance.id ]) redirect(action: "list") } else render(view: "create", model: [userInstance: userInstance]) } </code></pre> <p>I've added </p> <pre><code>def userRole = params.userRoles userRole.each { def userrole = Role.get(it) println userrole def userRoles = userInstance.addToUserRoles(userrole) } </code></pre> <p>this code in my user controller...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload