Be consistent checking changes in draft versions

There's no reason to only convert Markdown to HTML in translations when
their body changes but to always convert it when the "main" body field
changes.

Whether we should always use the condition or never use it is something
we can debate about, though.
This commit is contained in:
Javi Martín
2018-09-05 16:40:58 +02:00
parent cc6da6be28
commit a0f1a9ec1b

View File

@@ -26,8 +26,10 @@ class Legislation::DraftVersion < ActiveRecord::Base
renderer = Redcarpet::Render::HTML.new(with_toc_data: true)
toc_renderer = Redcarpet::Render::HTML_TOC.new(with_toc_data: true)
self.body_html = Redcarpet::Markdown.new(renderer).render(body)
self.toc_html = Redcarpet::Markdown.new(toc_renderer).render(body)
if body_changed?
self.body_html = Redcarpet::Markdown.new(renderer).render(body)
self.toc_html = Redcarpet::Markdown.new(toc_renderer).render(body)
end
translations.each do |translation|
if translation.body_changed?