diff --git a/README.md b/README.md index 0964e33d..2401aef1 100644 --- a/README.md +++ b/README.md @@ -65,15 +65,15 @@ Bellow is the list of bundled filters along with their optional arguments on ini ## Using AutoHtml with ActiveRecord -For performance reasons it's a good idea to store the formated output in the database in a separate column so that it's not generated every time. +For performance reasons it's a good idea to store the formated output in the database, in a separate column, to avoid generating the same content on each access. This can be acomplished simply by overriding the attribute writter: ```ruby class Comment < ActiveRecord::Base - FORMAT = AutoHtml::Pipeline.new( AutoHtml::HtmlEscape.new, - AutoHtml::Link.new(target: '_blank')) + AutoHtml::Markdown.new + ) def text=(t) super(t) @@ -82,6 +82,13 @@ class Comment < ActiveRecord::Base end ``` +Now, every time `text` attribute is set, `text_html` will be set as well: + +```Ruby +comment = Comment.new(text: 'Hey!') +comment.text_html # => '

Hey!

' +``` + ## Code status [![Circle CI](https://circleci.com/gh/dejan/auto_html.svg?style=svg&circle-token=57823c8b62302106564f97b58b64643b9760ed99)](https://circleci.com/gh/dejan/auto_html)