Class: C80News::Fact

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/c80_news/fact.rb

Instance Method Summary collapse

Instance Method Details

#normalize_friendly_id(input) ⇒ Object



18
19
20
# File 'app/models/c80_news/fact.rb', line 18

def normalize_friendly_id(input)
  input.to_s.to_slug.normalize(transliterations: :russian).to_s
end

#short_meta_descriptionObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/c80_news/fact.rb', line 26

def short_meta_description

  if description.present? && description.length > 200
    result = description
  elsif full.present? && full.length > 0
    result = strip_tags(full[0..200]+"...")
  else
    result = nil
  end
  result

end

#slug_candidatesObject



22
23
24
# File 'app/models/c80_news/fact.rb', line 22

def slug_candidates
  [:title] + Array.new(6) {|index| [:title, index+2]}
end

#thumb_lgObject



55
56
57
58
59
60
61
# File 'app/models/c80_news/fact.rb', line 55

def thumb_lg
  s = ''
  if fphotos.count > 0
    s = fphotos.first.image.thumb_lg
  end
  s
end

#thumb_mdObject



47
48
49
50
51
52
53
# File 'app/models/c80_news/fact.rb', line 47

def thumb_md
  s = ''
  if fphotos.count > 0
    s = fphotos.first.image.thumb_md
  end
  s
end

#thumb_previewObject



63
64
65
66
67
68
69
# File 'app/models/c80_news/fact.rb', line 63

def thumb_preview
  s = ''
  if fphotos.count > 0
    s = fphotos.first.image.thumb_preview
  end
  s
end

#thumb_smObject



39
40
41
42
43
44
45
# File 'app/models/c80_news/fact.rb', line 39

def thumb_sm
  s = ''
  if fphotos.count > 0
    s = fphotos.first.image.thumb_sm
  end
  s
end