3

See: Is there a CRUD generator utility in Java(any framework) like Scaffolding in Rails?

I have the same question but regarding Scala. I know Play framework 1.x had generators, but 2.x removed them, is there any working CRUD / Scaffolding generator for any Scala based web framework?

7
  • 1
    No, was some talk on the play user group about this, nothing planned. Twitter Bootstrap + DAO implementation + RESTful routing is your best bet; i.e. roll your own. Feb 1, 2013 at 15:42
  • @virtualeyes Thanks, I was worried it's the case. I was thinking tinkering with creating one for educational purposes, is there anything I should be aware of before I venture into this experiment? Anything to start off from?
    – Eran Medan
    Feb 1, 2013 at 15:55
  • 1
    Check the docs on integrating TB, pretty awesome, gives you a great headstart, CRUD with Play is fairly easy. Feb 1, 2013 at 16:29
  • @virtualeyes Thanks, pardon my ignorance, what does TB stand for? couldn't find it in the docs: google.com/…
    – Eran Medan
    Feb 1, 2013 at 16:32
  • Twitter Bootstrap, or a terrible disease -- in this case, it's the former ;-) Feb 1, 2013 at 16:47

2 Answers 2

2

I was searching for a scaffolding tool too (which popped your question) and found this: http://skinny-framework.org/documentation/scaffolding.html

I did not tried it yet but the doc looks like it's going to do the job:

./skinny g model tweet userId:Long text:String user:Option[User] will create

package model

import skinny.orm._, feature._
import scalikejdbc._
import org.joda.time._

// If your model has +23 fields, switch this to normal class and mixin scalikejdbc.EntityEquality.
case class Tweet(
  id: Long,
  userId: Long,
  text: String,
  user: Option[User] = None,
  createdAt: DateTime,
  updatedAt: DateTime
)

object Tweet extends SkinnyCRUDMapper[Tweet] with TimestampsFeature[Tweet] {

  override lazy val defaultAlias = createAlias("t")

  lazy val userRef = belongsTo[User](User, (t, u) => t.copy(user = u))

  /*
   * If you're familiar with ScalikeJDBC/Skinny ORM, using #autoConstruct makes your mapper simpler.
   * (e.g.)
   * override def extract(rs: WrappedResultSet, rn: ResultName[Tweet]) = autoConstruct(rs, rn)
   *
   * Be aware of excluding associations like this:
   * (e.g.)
   * case class Member(id: Long, companyId: Long, company: Option[Company] = None)
   * object Member extends SkinnyCRUDMapper[Member] {
   *   override def extract(rs: WrappedResultSet, rn: ResultName[Member]) =
   *     autoConstruct(rs, rn, "company") // "company" will be skipped
   * }
   */
  override def extract(rs: WrappedResultSet, rn: ResultName[Tweet]): Tweet = new Tweet(
    id = rs.get(rn.id),
    userId = rs.get(rn.userId),
    text = rs.get(rn.text),
    createdAt = rs.get(rn.createdAt),
    updatedAt = rs.get(rn.updatedAt)
  )
}

hope this helps!

1

Copying the answer from the comments in order to remove this question from the "Unanswered" filter:

No, was some talk on the play user group about this, nothing planned. Twitter Bootstrap + DAO implementation + RESTful routing is your best bet; i.e. roll your own.

...

Check the docs on integrating TB [Twitter Bootstrap], pretty awesome, gives you a great headstart, CRUD with Play is fairly easy.

~ answer per virtualeyes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.