Skip to content

Instantly share code, notes, and snippets.

@crockpotveggies
Created March 28, 2012 06:29
Show Gist options
  • Save crockpotveggies/2224233 to your computer and use it in GitHub Desktop.
Save crockpotveggies/2224233 to your computer and use it in GitHub Desktop.
Play! 2.0 is a meanie head so we slap that bitch with SquAction, a trait binding session to action thread
package controllers
import play.api.mvc._
import org.squeryl._
import org.squeryl.PrimitiveTypeMode._
/**
* bind a session to each action with this nifty Squeryl trait
*/
trait SquAction {
def SquAction(f: => Request[AnyContent] => Result) = {
Action(request => inTransaction { f(request) } )
}
}
package controllers
object Test extends Controller with SquAction {
def logout = SquAction {
Redirect( routes.Authentication.login ).withNewSession.flashing(
"notice" -> "Logout was successful."
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment