Add markdown functionality to any mongoid text field
MIT License
Add Markdown functionality to any Mongoid object.
class Message
include Mongoid::Document
include Mongoid::Markdown
field :body, :markdown => true
end
message = Message.new :body => "## Hello world"
message.marked_down? # => false
message.markdown!
message.marked_down? # => true
puts message.body # => "<h2>Hello world</h2>"
message.body = "## Goodbye cruel world..."
message.reload # not sure about this!
message.marked_down? # => true
Enjoy!
Extracted from: https://github.com/baphled/chat-engine/blob/master/lib/mongoid/markdown.rb
See specs for more usage examples
Should work on both Mongoid pre 2.4 and later, including 3.x.
Please help fix any bugs or come with suggestions to improvements.
== Copyright
Copyright (c) 2012 Kristian Mandrup. See LICENSE.txt for further details.