introducing active copy

If you've ever browsed the source code of this blog, you might have noticed a directory called lib/active_copy. Opening up that directory is somewhat interesting, as you'll be able to see exactly how I take Markdown files with YAML front matter and render them through ActionView. But unfortunately, unless you fork this repo and hack it to bits, you were unable to use ActiveCopy in your own Rails projects.

Until today.

I've released ActiveCopy to the world as a RubyGem and Rails plugin. While not mountable, ActiveCopy requires Rails, and especially ActionView, for all functionality to work properly.

so...what is it?

ActiveCopy is a replacement for ActiveRecord, but instead of being backed by a SQL database, it is backed by files which use a specific kind of markup format. ActiveCopy was born out of the necessity (or rather, desire) to "wrap Jekyll in a Rails app", giving one the benefits of Jekyll's static file template compilation and simple formatting, as well as Rails' deployment and testing toolchain. Additionally, the use of Rails allows me to experiment a bit with the features of this site, a prospect that would not be possible (in Ruby, anyway) with Jekyll.

get it working

First, add this to Gemfile:

gem 'active_copy'

Install the bundle:

$ bundle install

Now you can generate an ActiveCopy model:

$ rails generate copy article name title

You'll get a free generator that will generate files for you:

$ rails generate article the-id-of-my-article

ActiveCopy supports date prefixing, to do so, run:

$ rails generate copy article name title --datestamp

when you declare the generator for your model.

more information

You can view the complete documentation if you wish to get more involved with how the code works. But the README on GitHub is probably what you want to look at, as it contains a complete setup guide and usage information for the gem.