Skip to content

Instantly share code, notes, and snippets.

@evg2108
Last active August 29, 2015 14:20
Show Gist options
  • Save evg2108/38e572717ab7bb54ae39 to your computer and use it in GitHub Desktop.
Save evg2108/38e572717ab7bb54ae39 to your computer and use it in GitHub Desktop.
выборка по списку id (или по чему-нибудь другому) с сортировкой точно как в списке
ids = [1,8,4,9,2]
Article.where(id: ids).order(ids.map{|a| "id = #{a} desc"}.join(', '))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment