diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb
index b99963e2f..291a71f26 100644
--- a/app/controllers/praise_tread_controller.rb
+++ b/app/controllers/praise_tread_controller.rb
@@ -24,7 +24,7 @@ class PraiseTreadController < ApplicationController
end
return
end
- #@horizontal = params[:horizontal].downcase == "false" ? false:true
+ @horizontal = params[:horizontal].downcase == "false" ? false:true if params[:horizontal]
if @obj.respond_to?("author_id")
author_id = @obj.author_id
elsif @obj.respond_to?("user_id")
@@ -127,6 +127,8 @@ class PraiseTreadController < ApplicationController
@obj = Comment.find_by_id(id)
when 'Journal'
@obj = Journal.find_by_id(id)
+ else
+ @obj = nil
end
return @obj
end
@@ -143,7 +145,8 @@ class PraiseTreadController < ApplicationController
# end
#再创建或更新praise_tread_cache表
- @ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type)
+ #@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type)
+ @ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first
@ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc
@ptc.object_id = id.to_i
@ptc.object_type = type
diff --git a/app/views/praise_tread/_praise.html.erb b/app/views/praise_tread/_praise.html.erb
index 4fd961251..63b57f8a6 100644
--- a/app/views/praise_tread/_praise.html.erb
+++ b/app/views/praise_tread/_praise.html.erb
@@ -1,7 +1,13 @@
<% if PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",activity.id,activity.class.to_s,User.current.id).empty? %>
- 赞<%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ 赞
+ <% num = get_praise_num(activity) %>
+ <%= num > 0 ? "(#{num})" : "" %>
+
<% else %>
- 赞<%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ 已赞
+ <% num = get_praise_num(activity) %>
+ <%= num > 0 ? "(#{num})" : "" %>
+
<% end %>
\ No newline at end of file