Skip to content

Instantly share code, notes, and snippets.

@magnum
Last active December 20, 2015 16:48
Show Gist options
  • Save magnum/6163775 to your computer and use it in GitHub Desktop.
Save magnum/6163775 to your computer and use it in GitHub Desktop.
concatenate filters and and ordering
@categories = Categories.page params[:page]
@categories = @categories.order(params[:order_field] => params[:order_direction) unless params[:order_field].blank? || params[:order_direction].blank?
@categories = @categories.where(:attr1 => params[:p1]) unless params[:p1].blank? # (n times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment