X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/1340fca8f17e4e3cce211e6eafed18cde7f57386..8f4a9a4b870f7b15652eb125c675bf635c7b0484:/app/models/diary_entry.rb?ds=inline diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb index 1d836353f..64a412d28 100644 --- a/app/models/diary_entry.rb +++ b/app/models/diary_entry.rb @@ -25,4 +25,16 @@ class DiaryEntry < ActiveRecord::Base validates_associated :language attr_accessible :title, :body, :language_code, :latitude, :longitude + + after_initialize :set_defaults + + def body + RichText.new(read_attribute(:body_format), read_attribute(:body)) + end + +private + + def set_defaults + self.body_format = "markdown" unless self.attribute_present?(:body_format) + end end