I have two model classes: Book and User.
class Book {
Date date
String time
User futsal
String email
static constraints = {
}
}
class User {
String fullName
String futsalName
String location
String email
String password
String myUpload
static constraints = {
}
}
The login controller takes email and password and puts the user in a session.
package fullfinal
class LoginController {
def index() { }
def login(){
def email = params.email
def password = params.password
def user = User.findByEmailAndPassword(email,password);
if(user!=null){
session["u"] = user
}
def id = user.id
def books = Book.findAllByFutsal(id)
render(view:"dashboard" ,model:[u:session.u])
}
def dashboard(){
}
}
I am trying to retrieve all entries in Book whose value of "futsal" is equal to user id but I keep getting this error message:
No converter found capable of converting from type [java.lang.Long] to type [fullfinal.User]
I am not getting why and what should be converted here and how do I do it?
You should pass user object for finding book instead id.
def books = Book.findAllByFutsal(user)