Class: Rcms::Tiding

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
lib/generators/templates_tidings/app/models/rcms/tiding.rb

Instance Method Summary collapse

Instance Method Details

#get_short_desc(l = 110) ⇒ Object



15
16
17
# File 'lib/generators/templates_tidings/app/models/rcms/tiding.rb', line 15

def get_short_desc l = 110
  description.present? ? truncate(description, l) : truncate(text, l)
end

#truncate(text, l = 110) ⇒ Object



19
20
21
22
23
# File 'lib/generators/templates_tidings/app/models/rcms/tiding.rb', line 19

def truncate text, l = 110
  return nil if text.nil?
  text = ActionView::Base.full_sanitizer.sanitize(text)
  text.length > l ? text.truncate(l) : text
end