Reputation: 131
How I can get the ID of a saved object.
please give me an idea. because I am a beginner in grails
def saveCandidates(){
def candidate=new Candidates(
name: request.getParameter('name'),
email: request.getParameter('email'),
mobile: request.getParameter('mobile')
)
candidate.save()
//how i can get of candidate
redirect(uri: request.getHeader('referer'))
//redirect(url: request.header('referer'))
}
Upvotes: 2
Views: 333
Reputation: 1442
Once you save the domain
def candidate = new Candidates(
name: params.name,
email: params.email,
mobile: params.mobile)
candidate.save()
you can access the id by
candidate.id
Upvotes: 4