Permalink
Browse files

topics#show etag 标记修正 like,follow 动作过后无法更新的问题;

  • Loading branch information...
1 parent b09285b commit b3eada833934bddf278a608cf48a492de8f05246 @huacnlee huacnlee committed Dec 14, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 app/controllers/topics_controller.rb
@@ -56,6 +56,7 @@ def show
@topic.hits.incr(1)
@node = @topic.node
+
@per_page = Reply.per_page
# 默认最后一页
params[:page] = @topic.last_page_with_per_page(@per_page) if params[:page].blank?
@@ -68,12 +69,16 @@ def show
@replies.each { |r| @user_liked_reply_ids << r.id if r.liked_user_ids.include?(current_user.id) }
# 通知处理
current_user.read_topic(@topic)
+ # 是否关注过
+ @has_followed = @topic.follower_ids.include?(current_user.id)
+ # 是否收藏
+ @has_favorited = current_user.favorite_topic_ids.include?(@topic.id)
end
set_seo_meta("#{@topic.title} &raquo; #{t("menu.topics")}")
drop_breadcrumb("#{@node.try(:name)}", node_topics_path(@node.try(:id)))
drop_breadcrumb t("topics.read_topic")
- fresh_when(:etag => [@topic,@replies,@node])
+ fresh_when(:etag => [@topic,@has_followed,@has_favorited,@replies,@node])
end
def new

0 comments on commit b3eada8

Please sign in to comment.