diff --git a/app/models/story.rb b/app/models/story.rb index 2acb65f..9300544 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -387,6 +387,10 @@ class Story < ActiveRecord::Base self.user_id, nil, false) end + def score + upvotes - downvotes + end + def short_id_path Rails.application.routes.url_helpers.root_path + "s/#{self.short_id}" end @@ -395,8 +399,8 @@ class Story < ActiveRecord::Base Rails.application.root_url + "s/#{self.short_id}" end - def score - upvotes - downvotes + def sorted_taggings + self.taggings.sort_by{|t| t.tag.tag }.sort_by{|t| t.tag.is_media?? -1 : 0 } end def tagging_changes diff --git a/app/views/stories/_listdetail.html.erb b/app/views/stories/_listdetail.html.erb index d36aba7..89e63be 100644 --- a/app/views/stories/_listdetail.html.erb +++ b/app/views/stories/_listdetail.html.erb @@ -23,8 +23,7 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ? <% if story.can_be_seen_by_user?(@user) %> - <% story.taggings.sort_by{|t| t.tag.tag }.sort_by{|t| - t.tag.is_media?? -1 : 0 }.each do |tagging| %> + <% story.sorted_taggings.each do |tagging| %> <%= tagging.tag.tag %> @@ -40,8 +39,7 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ? <%= ms.title %> - <% ms.taggings.sort_by{|t| t.tag.tag }.sort_by{|t| - t.tag.tag == "pdf" ? -1 : 0 }.each do |tagging| %> + <% ms.sorted_taggings.each do |tagging| %> <%= tagging.tag.tag %>