表中有updated_at和last_viewed_at两个字段,原意是想记录修改时间和最后访问时间.
于是在controller中做了一个after_filter:
相应的方法:
现在问题来了,使用update_attributes方法更新last_viewed_at字段,可是同时updated_at字段也随之更新了...
解决方法探究中...
于是在controller中做了一个after_filter:
after_filter:update_last_viewed,:only => "show"
相应的方法:
def update_last_viewed
@group.update_attributes(:last_viewed => Time.now)
end
def show
@group = Group.find(params[:id])
end
现在问题来了,使用update_attributes方法更新last_viewed_at字段,可是同时updated_at字段也随之更新了...
解决方法探究中...