Created
September 19, 2012 22:18
-
-
Save brettchalupa/3752704 to your computer and use it in GitHub Desktop.
Sorting and displaying Submissions and their Favorite count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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