我是Grails的新手。我正在使用Rateable Plugin在我的grail应用程序中集成用户评级功能。我正在这样...
安装
grails install-plugin rateable
我的Post.groovy域类-
package groovypublish
import org.grails.twitter.Person
import org.grails.rateable.*
class Post implements Rateable {
static hasMany = [comments:Comment]
String title
String teaser
String content
Date lastUpdated
Boolean published = false
SortedSet comments
Person author
static searchable = [only: 'title']
static constraints = {
title(nullable:false, blank:false, length:1..50)
teaser(length:0..100)
content(nullable:false, blank:false)
lastUpdated(nullable:true)
published(nullable:false)
}
}
我在_post.gsp文件中使用的标签...
<rateable:ratings bean='${post}'/>
我的星级评分正在显示...
当用户给出评分时,它将显示为..
但评级未保存在数据库中。
当我再次刷新页面时,它显示(0个评分)。我不知道为什么我的等级未保存在数据库中。我正在使用Spring Security Core Plugin进行身份验证。有任何建议吗?
更新:-
我在我的Config.groovy文件中添加了
grails.rateable.rater.evaluator = { request.user }
行。但是它显示错误:URI
/groovypublish/rateable/rate/1
Class
org.grails.rateable.RatingException
Message
No [grails.rateable.rater.evaluator] setting defined or the evaluator doesn't evaluate to an entity. Please define the evaluator correctly in grails-app/conf/Config.groovy or ensure rating is secured via your security rules
最佳答案
I am using Spring Security Core Plugin for Authentication purpose
在这种情况下,您可能想要类似
grails.rateable.rater.evaluator = {
grailsApplication.mainContext.springSecurityService.currentUser
}
关于grails - Grails Rateable插件未在数据库中保存评分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17565017/