Skip to content

Instantly share code, notes, and snippets.

@jrolfs
Last active December 10, 2015 23:08
Show Gist options
  • Select an option

  • Save jrolfs/4507562 to your computer and use it in GitHub Desktop.

Select an option

Save jrolfs/4507562 to your computer and use it in GitHub Desktop.
order = params[:sort].to_sym rescue :published_at
direction = params[:order] == "asc" ? order = order.asc : order = order.desc
@videos = Youtubevideo.where(query_params).paginate({
:order => order,
:per_page => per_page,
:page => page
})
@ashrewdmint
Copy link

order = params[:sort].to_sym rescue :published_at

direction = params[:order] == "asc" ? :asc : :desc
@videos = Youtubevideo.where(query_params).send(direction, order).paginate(paging)

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