Class: Note

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/note.rb

Instance Method Summary collapse

Instance Method Details

#auto_set_valueObject



14
15
16
17
18
19
# File 'app/models/note.rb', line 14

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

#display_titleObject



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

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

#update_changes_countObject



22
23
24
25
# File 'app/models/note.rb', line 22

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