Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created October 28, 2010 03:32
Show Gist options
  • Select an option

  • Save chanwit/650572 to your computer and use it in GitHub Desktop.

Select an option

Save chanwit/650572 to your computer and use it in GitHub Desktop.
// from: http://adammonsen.com/post/548
detectMobile (controller:'*', action:'*') {
before = {
if (request.getHeader('user-agent') =~ /(?i)iphone/) {
request['isMobile'] = true
} else {
request['isMobile'] = false
}
return true // keep processing other filters and the action
}
after = { }
afterView = { }
}
def afterInterceptor = { model, modelAndView ->
if (request['isMobile']) {
modelAndView.viewName = modelAndView.viewName + "_m"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment