Last active
August 29, 2015 14:01
-
-
Save chadbailey59/11546306 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# lib/download_counter.rb | |
def downloads_for(records) | |
ids = records.all.each.map(&:uuid).join(",") | |
JSON.parse(Excon.get("/downloads?uuids=#{ids}")) | |
end | |
# controller | |
def index | |
@episodes = Episode.find_all_by_whatever | |
@downloads = DownloadCounter.downloads_for(@episodes) | |
end | |
# view | |
@episodes.each do |episode| | |
<h2><%= episode.title %></h2> | |
<p>Downloads: <%= @downloads[episode] %></p> | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't believe I paid for this.