score:1
Accepted answer
I have managed to solve it likewise:
MusicController.scala
def show(id: Long) = Action.async { implicit request =>
repo.findById(id).map { music =>
Ok(views.html.musics.show(music))
}
}
MusicRepository.scala
def findById(id: Long): Future[Music] = db.run {
musics.filter(_.id === id).result.head
}
Source: stackoverflow.com
Related Query
- How to fetch records from the database using Play with Scala and Slick
- Using play framework and scala how to display image path from database
- How to select multiple column from database using scala Play2.6 and with proper json response header
- How to show images using Play framework and Scala in the view page
- One-to-many relationship between tables on different files using Play with Scala and Slick
- How to create an instance of a model with the ebean framework and scala in Play 2.2
- Using the Play WS API from pure Scala with sbt
- How to extract binary information from a database using Anorm with Scala
- How to map multiple Futures and pass them as arguments to a view using Play with Scala
- "Error injecting constructor" when mapping Enumeration using Slick 3.1 with play and scala
- How to send email with attached file in scala and play framework (2.3.9) using activator?
- how to insert data into database using play framework and scala
- Best practices to separate business logic from the Controller to the Model layer with Play framework + Scala + Slick
- Read Nested List from Database with relation and Create another List using Scala Recursivly
- Using Scala Slick retrieve all records from SQL db where date from timestamp column falls in the last month or last week
- how to change the form style created using helper in play 2.1.0 with scala
- How to filter the data from Rdd and save it to text file using scala in spark
- How to get all S3ObjectSummary from an S3 bucket using scala and the aws-java-sdk?
- Using Scala Play and Slick, how do I pass non-trivial relationships to the view
- How do you read the HTML content of an Atom feed with Scala and Play framework 2.0?
- How to use IntelliJ with Play Framework and Scala
- How to load JSON file using Play with Scala
- How to download and save a file from the internet using Scala?
- How to get Scala imports working in IntelliJ IDEA with the Play framework?
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- How to create a Scala class with private field with public getter, and primary constructor taking a parameter of the same name
- How can I idiomatically "remove" a single element from a list in Scala and close the gap?
- Slick 3.0: Idiomatic way to GET results from the database inside of Option (Scala Play Framework)
- How can I deserialize from JSON with Scala using *non-case* classes?
- Check if element exists in database using Slick 3 and Play
More Query from same tag
- Type parameter of minBy[B](f: ((A, B)) ⇒ B)(implicit cmp: Ordering[B]): (A, B)
- Possible to test for exhaustivity of match of macro-generated types
- Trying to calculate memory occupied by objects
- Apache Solr [embedded] collection not found error in test cases
- Implicits and order of declaration
- Scala - java.lang.VerifyError with simple function
- simple scala help:llegal start of simple expression
- How to run gsutil from Scala without the .cmd suffix?
- SBT: Accessing setting values of subprojects in scala build
- Scala nested optionals chaining in object
- Akka, Camel and ActiveMQ: throttling consumers
- Overriding vals in Scala
- Writing function parameters before function to be applied in Scala
- Is there an equivalent of Python's difflib.SequenceMatcher for Scala
- Scala system.shutdown not working
- Is it correct to use `Future` to run some loop task which is never finished?
- In Scala.js, how can code detect whether it is running in a browser window or a WebWorker?
- Why is the message "The global sbt directory is now versioned" in 0.13?
- What is the difference between these two map expressions in Scala/Python?
- Does use of Future.successful and Future.failed request a thread from the thread pool managed by the execution context
- Why would Scala Range iterator buffer -- sometimes?
- Inconsistent behaviour when an exception is thrown in a for comprehension
- How to run gatling from multiple git repositories
- multipart/form-data using scala-dispatch
- Scala extended constructor
- sbt-proguard: make two jars
- Installing GeoMesa on Databricks
- shapeless record get value by Symbol
- Scala spark: Access value in a struct in an array-typed column? (Or, access member of anonymous struct-typed column)
- Out of memory error Error while building spark