Skip to content

Instantly share code, notes, and snippets.

@datapimp
Created January 14, 2011 20:44
Show Gist options
  • Select an option

  • Save datapimp/780198 to your computer and use it in GitHub Desktop.

Select an option

Save datapimp/780198 to your computer and use it in GitHub Desktop.
scoped = order("#{ sort_by } #{ direction }")
scoped = scoped.where( :publisher_id => params[:publisher_id] ) if params[:publisher_id].present?
scoped = scoped.where( :category_id => params[:category_id] ) if params[:category_id].present?
scoped = scoped.where( "title like ?", "%#{ params[:title] }%" ) if params[:title].present?
scoped = scoped.where( "description like ?", "%#{ params[:description] }%" ) if params[:description].present?
scoped = scoped.drafts if params[:drafts_only].present?
scoped = scoped.published if params[:published_only].present?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment