I have started learning about Play, and in the tutorials that I saw, the model usually has two components: a case class
and an object
.
I have created a model with an object and a case class. My question is how do I reference a field(declared in the case class) from the object:
package models
import java.net.URL
import play.api.Logger
import play.api.db.DB
import play.api.libs.json.Json
case class Page(url: String)
object Page {
implicit val personFormat = Json.format[Page]
def readPageContent(): String = {
var content: String = new URL(this.url).getContent().toString
return content
}
}
For instance, here in the object, I am trying to reference the field url
using this.url
, but I get cannot resolve symbol url
.
How can I reference the field?