Commit e7b93cf4cf01880aa94c7e6f38d9faffda1f4c40

Authored by Antonio Terceiro
1 parent a89d2b9e

Removing in-house touch method for ActiveRecord

The touch method provided by Rails 2.3.5 actually has a different
semantics, and since it was only used in two places, it's better to
inline the semantics we wanted.
app/controllers/public/content_viewer_controller.rb
@@ -105,7 +105,7 @@ class ContentViewerController < ApplicationController @@ -105,7 +105,7 @@ class ContentViewerController < ApplicationController
105 @comment.author = user if logged_in? 105 @comment.author = user if logged_in?
106 @comment.article = @page 106 @comment.article = @page
107 if @comment.save 107 if @comment.save
108 - @page.touch 108 + @page.update_attribute(:updated_at, Time.now)
109 @comment = nil # clear the comment form 109 @comment = nil # clear the comment form
110 redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] 110 redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view]
111 else 111 else
app/sweepers/article_sweeper.rb
@@ -15,7 +15,7 @@ protected @@ -15,7 +15,7 @@ protected
15 def expire_caches(article) 15 def expire_caches(article)
16 article.hierarchy.each do |a| 16 article.hierarchy.each do |a|
17 if a != article 17 if a != article
18 - a.touch 18 + a.update_attribute(:updated_at, Time.now)
19 end 19 end
20 end 20 end
21 blocks = article.profile.blocks 21 blocks = article.profile.blocks
vendor/plugins/touch/init.rb
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -if ActiveRecord::Base.instance_methods.include?("touch") && Class.const_defined?('TOUCH_LOADED')  
2 - puts "W: ActiveRecord already provides a touch method, which means you must be using rails 2.3.3 or later."  
3 - puts "W: In this case the touch plugin could probably be removed"  
4 -end  
5 -TOUCH_LOADED = true  
6 -  
7 -module Touch  
8 - def touch  
9 - update_attribute(:updated_at, Time.now)  
10 - end  
11 -end  
12 -  
13 -ActiveRecord::Base.send(:include, Touch)