Class: Note

Inherits:
ApplicationRecord show all
Includes:
BaseModel, Redis::Objects
Defined in:
app/models/note.rb

Overview

记事本

Instance Method Summary collapse

Methods included from BaseModel

#pull, #push

Instance Method Details

#auto_set_valueObject


18
19
20
21
22
23
# File 'app/models/note.rb', line 18

def auto_set_value
  unless body.blank?
    self.title = body.split("\n").first[0..50]
    self.word_count = body.length
  end
end

#display_titleObject


31
32
33
# File 'app/models/note.rb', line 31

def display_title
  (title || "").gsub(/^[\#]+/, '')
end

#update_changes_countObject


26
27
28
29
# File 'app/models/note.rb', line 26

def update_changes_count
  self.changes_count = 0 if changes_count.blank?
  increment(:changes_count)
end