X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/1340fca8f17e4e3cce211e6eafed18cde7f57386..2638cd525262321f28479e5c5598866b4e2fd93e:/app/models/diary_entry.rb 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