Topic: Textile and Rails

I am pretty much hooked on Textile these days and am wondering the best way to implement it on my projects. Obviously I have installed whytheluckystiff's Redcloth gem, but my next step is not so clear.

One thing that has me wondering, was my digging into the database structure of Textpattern (the makers of Textile)

I notice that they have set two different columns for textilized content. One column holds the actual text input by the user, while another column keeps a copy of the HTML version. It seems like a clever way to cache your content so that Textile doesnt need to be parsed for every request.

Is this the smartest way to approach this, or am I bloating my database?

If it is the way to go, how should I parse and save the content?

Re: Textile and Rails

If you're in the view, you can use the textilize method.

If you want to do it elsewhere (in the model) you need to do this:

I wouldn't cache it in the database unless you know you need to. If you need to, however, the best spot for that is a before_save callback.

Railscasts - Free Ruby on Rails Screencasts

Re: Textile and Rails

So weird, I been getting the "Precondition Failed" error on the api a lot lately. Cant see what that link leads to, but honestly I will probably save this content in my model. I think I figred out how to work my model, but something is still missing:

# :title, :title_html, :body, :body_html
class Post < ActiveRecord::Base

  before_save :textile_db

  def textile_db
    self.title =
    self.body =


1. How does Rails know to save the HTML version into the specified column?
2. How does Rails update both columns if an article is edited?

Re: Textile and Rails

I found a plugin that does exactly what I am looking for: … umn/README

I also found another plugin that takes a much simpler route without column copies

Why reinvent the wheel right?