skinny frameworkのscaffoldで生成する方法
./skinny g scaffold:{テンプレート種類} {複数形} {単数形} {フィールド名1}:{型名} {フィールド名2}:{型名}
または
| case class Id[T](id:Int) { | |
| override def toString = "id:"+this.id.toString | |
| def == (other: Id[T]) : Boolean = toString == other.toString | |
| def next = Id(id + 1) | |
| } | |
| object AutoId { | |
| var _v : Int = 0 | |
| def apply[T](): Id[T] = { | |
| _v += 1 |
| package model | |
| import skinny.orm._, feature._ | |
| import scalikejdbc._, SQLInterpolation._ | |
| import org.joda.time._ | |
| case class Post( | |
| id: Long, | |
| title: String, | |
| body: String, |
| Post.join(Post.tagsRef).findById(1) // byDefault抜け |
| package skinny.mail | |
| import java.util.{ Date, Properties } | |
| import javax.mail._ | |
| import javax.mail.Message.RecipientType._ | |
| import javax.mail.internet.{ MimeMultipart, MimeBodyPart, InternetAddress, MimeMessage } | |
| import javax.activation.{ FileDataSource, DataHandler } | |
| trait SkinnyMailer { config: SkinnyMailerConfig => | |
| def getProperties = { |
| $.extend({ | |
| version:function() { | |
| var v = $($().jquery.split(".")).map(function(){ return parseInt(this,10);}) | |
| return { | |
| major:v[0], | |
| minor:v[1], | |
| revision:v[2] | |
| } | |
| }, | |
| isOldVersion:function(major, minor, revision) { |
| class E[A](a:A) { | |
| def ~>(f:A => Any) = { | |
| f(a) | |
| this | |
| } | |
| def >>=[B](f:A => B) = f(a) | |
| } | |
| object E { |
| jQuery.Event.prototype.getPageX = function() { | |
| return this.originalEvent.touches ? this.originalEvent.touches[0].pageX : this.pageX; | |
| }; | |
| jQuery.Event.prototype.getPageY = function() { | |
| return this.originalEvent.touches ? this.originalEvent.touches[0].pageY : this.pageY; | |
| }; |
| import org.specs2.mutable._ | |
| class HelperSpec extends Specification { | |
| "nlbr" should { | |
| "newline character will be <br />" in { | |
| views.html.helper.nlbr("foo\nbar").toString must contain ("<br />") | |
| views.html.helper.nlbr("foo\r\nbar").toString must contain ("<br />") | |
| views.html.helper.nlbr("foo\rbar").toString must contain ("<br />") | |
| } |