Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Reverse routes problem when Option is present? #187

Closed
futurechimp opened this Issue May 3, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Member

futurechimp commented May 3, 2012

Hi,

I've been having a few problems today with reverse routing support.

This works, providing the expected redirect to:
http://localhost:8080/uploads/show/4fa1cd5844aec38278f679e8

val _id = UploadGroupDAO.insert(group)
 redirect("/uploads/show/" + _id.getOrElse(""))

I would expect this to work as well, and it sort of does:

 val _id = UploadGroupDAO.insert(group).toString
 redirect(url(uploadsShow, "id" -> _id))

This compiles OK, but redirects to:
http://localhost:8080/uploads/show/Some(4fa1cd5844aec38278f679e8)

Something else I'd think would work is this:

    val _id = UploadGroupDAO.insert(group)
    redirect(url(uploadsShow, "id" -> _id.getOrElse("")))

However this brings back a compiler error:

overloaded method value url with alternatives:
[error]   (route: org.scalatra.Route,params: Map[String,String],splats: Iterable[String])String <and>
[error]   (route: org.scalatra.Route,splat: String,moreSplats: String*)String <and>
[error]   (route: org.scalatra.Route,params: (String, String)*)String
[error]  cannot be applied to (org.scalatra.Route, (java.lang.String, Any))
[error]     redirect(url(uploadsShow, "id" -> _id.getOrElse("")))

I'll take a peek at this tomorrow, just figured I'd log it here before I forgot about it.

Member

futurechimp commented May 4, 2012

@casualjim figures the problem is here:

https://github.com/scalatra/scalatra/blob/develop/core/src/main/scala/org/scalatra/ScalatraBase.scala#L470

...but I'm not familiar enough with the test structure yet to write a failing test, and then a change to make it pass.

@casualjim casualjim closed this in 8aae79c May 4, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment