Skip to content

Instantly share code, notes, and snippets.

@himanoa
Created April 1, 2019 18:44
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 himanoa/82f387bc3997d83deea9d17ed903616b to your computer and use it in GitHub Desktop.
Save himanoa/82f387bc3997d83deea9d17ed903616b to your computer and use it in GitHub Desktop.
# -*- 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