找到这个:http ://clothred.rubyforge.org/
这是:https ://github.com/jystewart/html2textile
这是:https ://github.com/mattt/pricetag
编辑
我选择了 html2textile。我使用我问的这个 SO question中的说明安装了它。
然后我在 /lib/tasks/app.rake 中创建了一个名为 Textile_ize 的任务。它看起来像这样:
namespace :db do
desc "Convert html to textile on desc columns"
task :textile_ize => :environment do
puts "Starting Desc"
contents = Content.all
contents.each do |c|
#desc
parser = HTMLToTextileParser.new
parser.feed(c.desc)
c.desc_textile = parser.to_textile
c.save
end
puts "Finished with Desc"
end
然后我可以跑步rake db:textile_ize
和噗,完成。我实际上添加了一个额外的列来存储纺织品并使用:before_save
. 看起来像这样(在我的模型中):
before_save :textile_ize
# convert textile to html
def textile_ize
self.desc = RedCloth.new(self.desc_textile).to_html
end
希望这可以帮助那里的人!