Story: sort

This commit is contained in:
Carl Chenet 2017-05-20 15:13:26 +02:00
parent 5dc024568a
commit db3384f974

View file

@ -315,6 +315,20 @@ class Story < ActiveRecord::Base
end
end
def fix_bogus_chars
# this is needlessly complicated to work around character encoding issues
# that arise when doing just self.title.to_s.gsub(160.chr, "")
self.title = self.title.to_s.split("").map{|chr|
if chr.ord == 160
" "
else
chr
end
}.join("")
true
end
def generated_markeddown_description
Markdowner.to_html(self.description, { :allow_images => true })
end
@ -476,20 +490,6 @@ class Story < ActiveRecord::Base
self.user_id, nil, false)
end
def fix_bogus_chars
# this is needlessly complicated to work around character encoding issues
# that arise when doing just self.title.to_s.gsub(160.chr, "")
self.title = self.title.to_s.split("").map{|chr|
if chr.ord == 160
" "
else
chr
end
}.join("")
true
end
def score
upvotes - downvotes
end