Skip to content

Instantly share code, notes, and snippets.

@chadbailey59
Last active August 29, 2015 14:01
Show Gist options
  • Save chadbailey59/11546306 to your computer and use it in GitHub Desktop.
Save chadbailey59/11546306 to your computer and use it in GitHub Desktop.
# 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
@dan
Copy link

dan commented May 5, 2014

I can't believe I paid for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment