Skip to content

Instantly share code, notes, and snippets.

@brettchalupa
Created September 19, 2012 22:18
Show Gist options
  • Save brettchalupa/3752704 to your computer and use it in GitHub Desktop.
Save brettchalupa/3752704 to your computer and use it in GitHub Desktop.
Sorting and displaying Submissions and their Favorite count
@submissions = Submission.all.sort_by { |s| s.favorites.count }
File.open("favorites_list.txt", "w") do |file|
@submissions.each do |submission|
file << submission.name + " - Favorites: " + submission.favorites.count.to_s + "\n"
end
end
@submissions = Submission.all
File.open("favorites_list.txt", "w") do |file|
@submissions.each do |submission|
file << submission.id.to_s + " - " + submission.name + " - Favorites: " + submission.favorites.count.to_s + "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment