改了论坛回复不会触发修改update字段的问题

This commit is contained in:
yanxd 2013-12-27 15:04:05 +08:00
parent fea1cdff53
commit 8bc5b2ebf5
2 changed files with 7 additions and 5 deletions

View File

@ -57,7 +57,7 @@ class MemosController < ApplicationController
pre_count = REPLIES_PER_PAGE
@memo = @memo.root # 取出楼主防止输入帖子id让回复作为主贴显示
@memo.update_attribute(:viewed_count, @memo.viewed_count.to_i + 1)
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
page = params[:page]
if params[:r] && page.nil?
@ -95,11 +95,12 @@ class MemosController < ApplicationController
def update
respond_to do |format|
if( @memo.update_attribute(:subject, params[:memo][:subject]) &&
@memo.update_attribute(:content, params[:memo][:content]) &&
@memo.update_attribute(:sticky, params[:memo][:sticky]) &&
@memo.update_attribute(:lock, params[:memo][:lock]))
if( @memo.update_column(:subject, params[:memo][:subject]) &&
@memo.update_column(:content, params[:memo][:content]) &&
@memo.update_column(:sticky, params[:memo][:sticky]) &&
@memo.update_column(:lock, params[:memo][:lock]))
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
# @memo.root.update_attribute(:updated_at, @memo.updated_at)
format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"}
else
format.html { render action: "edit" }

View File

@ -65,6 +65,7 @@ class Memo < ActiveRecord::Base
def reset_counters!
if parent && parent.id
Memo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
parent.update_attribute(:updated_at, Time.now)
end
forum.reset_counters!
end