Created
January 18, 2016 13:45
-
-
Save billie66/2f4787f35d5cb827f07c 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
# 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