Created
April 1, 2019 18:44
-
-
Save himanoa/82f387bc3997d83deea9d17ed903616b to your computer and use it in GitHub Desktop.
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
# -*- encoding: utf-8 -*- | |
require "active_record" | |
require "erb" | |
config = YAML.load_file( './database.yml' ) | |
ActiveRecord::Base.establish_connection(config["db"]["development"]) | |
class Entry < ActiveRecord::Base | |
end | |
Entry.all.to_a.each do |entry| | |
body = <<"EOS" | |
+++ | |
date = "#{entry.updated_at.strftime('%Y-%m-%d')}" | |
title = "#{entry.title}" | |
author = "himanoa" | |
+++ | |
#{entry.body} | |
EOS | |
File.write("content/#{entry.id}.md", body) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment