diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index be8cbc9a6..36d9251e1 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -9,7 +9,13 @@ class PraiseTreadController < ApplicationController if @pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first end + @activity = false if request.get? + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end @obj_id = params[:obj_id] @obj_type = params[:obj_type] #@horizontal = params[:horizontal].downcase == "false" ? false:true @@ -17,13 +23,12 @@ class PraiseTreadController < ApplicationController unless @obj.author_id == User.current.id praise_tread_plus(@obj_type,@obj_id,1) end - @user_activity_id = params[:user_activity_id] if params[:user_activity_id] - @type = params[:type] if params[:type] - end + end end def praise_minus @obj = nil + @activity = false if request.get? #@obj = params[:obj] # 传的是对象,最后变成id了 @obj_id = params[:obj_id] @@ -43,8 +48,11 @@ class PraiseTreadController < ApplicationController end #@obj = User.find_by_id(@obj) @obj = find_object_by_type_and_id(@obj_type,@obj_id) - @user_activity_id = params[:user_activity_id] if params[:user_activity_id] - @type = params[:type] if params[:type] + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end respond_to do |format| format.js end diff --git a/app/views/praise_tread/_praise.html.erb b/app/views/praise_tread/_praise.html.erb index 9059f1628..b1a14bb81 100644 --- a/app/views/praise_tread/_praise.html.erb +++ b/app/views/praise_tread/_praise.html.erb @@ -1,7 +1,7 @@ <% 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)})" : "" %> <% else %> - + <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %> <% end %> \ No newline at end of file diff --git a/app/views/praise_tread/praise_minus.js.erb b/app/views/praise_tread/praise_minus.js.erb index 63efe303c..63d30d3a5 100644 --- a/app/views/praise_tread/praise_minus.js.erb +++ b/app/views/praise_tread/praise_minus.js.erb @@ -1,4 +1,4 @@ -<% if @user_activity_id %> +<% if @activity %> <% if @type.to_s == 'activity' %> $('#praise_count_<%=@user_activity_id %>').html('<%= j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>'); <% else %> diff --git a/app/views/praise_tread/praise_plus.js.erb b/app/views/praise_tread/praise_plus.js.erb index 30b28fff1..ce14ec1f8 100644 --- a/app/views/praise_tread/praise_plus.js.erb +++ b/app/views/praise_tread/praise_plus.js.erb @@ -2,7 +2,7 @@ $('#praise_tread_<%= @obj.id %>').html('<%= j( render :partial => "/memos/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal} )%>'); -<% elsif @user_activity_id %> +<% elsif @activity %> <% if @type.to_s == 'activity' %> $('#praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>'); <% else %>