I am using the play-salat plugin with an app I am making with Play! 2.0 scala.
I get the Duplicate Key error, and the compiler points here to the error:
object Post extends ModelCompanion[Post, ObjectId]
I have read that this can be fixed in PHP here doing an unset, please tell me how to do this with Play.
I am able to post in my database the once, when I try again I get the error.
def save = Action { implicit request =>
postForm.bindFromRequest.fold(
formWithErrors => BadRequest(html.newpost(formWithErrors)),
post => {
Post.insert(post)
Home
}
)
}
val postForm = Form(
mapping(
"_id" -> ignored(new ObjectId()),
"title" -> nonEmptyText,
"content" -> nonEmptyText,
"posted" -> date("yyyy-MM-dd"),
"modified" -> optional(date("yyyy-MM-dd")),
"tags" -> nonEmptyText,
"categories" -> nonEmptyText,
"userId" -> nonEmptyText
)(Post.apply)(Post.unapply)
)