优化project_controller show方法

This commit is contained in:
huang 2016-03-22 12:42:53 +08:00
parent 341308658d
commit 478311128d
2 changed files with 4 additions and 4 deletions

View File

@ -852,7 +852,7 @@ class CoursesController < ApplicationController
# return
# end
# 统计访问量
@course.update_attribute(:visits, @course.visits.to_i + 1)
@course.update_column(:visits, @course.visits.to_i + 1)
#更新创建课程消息状态
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
create_course_messages.update_all(:viewed => true)

View File

@ -295,11 +295,13 @@ class ProjectsController < ApplicationController
def show
# 更新消息为已读
update_message_status(User.current, @project)
# over
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
# 统计访问量
@project.update_attribute(:visits, @project.visits.to_i + 1)
@project.update_column(:visits, @project.visits + 1)
# over
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
@page = params[:page] ? params[:page].to_i + 1 : 0
# 根据私密性,取出符合条件的所有数据
@ -321,8 +323,6 @@ class ProjectsController < ApplicationController
= ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc")
.page(params['page'|| 1]).per(10);
end
boards = @project.boards.includes(:last_message => :author).all
@topic_count = @project.boards.count
# 根据对应的请求,返回对应的数据
respond_to do |format|
format.html