Skip to content

Instantly share code, notes, and snippets.

@billie66
Created January 18, 2016 13:45
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 billie66/2f4787f35d5cb827f07c to your computer and use it in GitHub Desktop.
Save billie66/2f4787f35d5cb827f07c to your computer and use it in GitHub Desktop.
# encoding: UTF-8
# happycasts database
namespace :db do
desc "get episods' info from the table episods"
task :episodes => :environment do
posts = []
Episode.all.each do |e|
post = {}
post['id'] = e.id
post['name'] = e.name
post['title'] = e.title
post['created_at'] = e.created_at.strftime('%Y年%-m月%-d日')
posts << post
end
result = JSON.pretty_generate(posts)
File.open('hdsp-episodes', 'w'){ |f| f.write(result) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment