Skip to content

Instantly share code, notes, and snippets.

@errakeshpd
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save errakeshpd/83c6fc29f22fe73251d4 to your computer and use it in GitHub Desktop.
Save errakeshpd/83c6fc29f22fe73251d4 to your computer and use it in GitHub Desktop.
How can specify this ruby code in the lambda section
How can specify this ".sort_by{ |o| o.reviews.sum(:rating) }" in the lambda section
scope :sort_by_recommended, lambda{ }
Just like this :
scope :sort_by_recommended, lambda{ .sort_by{ |o| o.reviews.sum(:rating) } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment