Skip to content

Instantly share code, notes, and snippets.

Created May 5, 2015 10:23
Show Gist options
  • Save anonymous/3c85c489618bd8e14284 to your computer and use it in GitHub Desktop.
Save anonymous/3c85c489618bd8e14284 to your computer and use it in GitHub Desktop.
def index
sortorder = ["asc", "desc"].include? params[:order] ? params[:order] || 'asc'
sortby = ["name", "address"].include? params[:sortby] ? params[:sortby] || 'name'
@users = User.all.order(sortby => sortorder)
render 'v1/users/index'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment