From e7b93cf4cf01880aa94c7e6f38d9faffda1f4c40 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Wed, 23 Feb 2011 11:39:31 -0300 Subject: [PATCH] Removing in-house touch method for ActiveRecord --- app/controllers/public/content_viewer_controller.rb | 2 +- app/sweepers/article_sweeper.rb | 2 +- vendor/plugins/touch/init.rb | 13 ------------- 3 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 vendor/plugins/touch/init.rb diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index a296f7c..41ced0f 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -105,7 +105,7 @@ class ContentViewerController < ApplicationController @comment.author = user if logged_in? @comment.article = @page if @comment.save - @page.touch + @page.update_attribute(:updated_at, Time.now) @comment = nil # clear the comment form redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] else diff --git a/app/sweepers/article_sweeper.rb b/app/sweepers/article_sweeper.rb index 30b3232..1005910 100644 --- a/app/sweepers/article_sweeper.rb +++ b/app/sweepers/article_sweeper.rb @@ -15,7 +15,7 @@ protected def expire_caches(article) article.hierarchy.each do |a| if a != article - a.touch + a.update_attribute(:updated_at, Time.now) end end blocks = article.profile.blocks diff --git a/vendor/plugins/touch/init.rb b/vendor/plugins/touch/init.rb deleted file mode 100644 index df721a4..0000000 --- a/vendor/plugins/touch/init.rb +++ /dev/null @@ -1,13 +0,0 @@ -if ActiveRecord::Base.instance_methods.include?("touch") && Class.const_defined?('TOUCH_LOADED') - puts "W: ActiveRecord already provides a touch method, which means you must be using rails 2.3.3 or later." - puts "W: In this case the touch plugin could probably be removed" -end -TOUCH_LOADED = true - -module Touch - def touch - update_attribute(:updated_at, Time.now) - end -end - -ActiveRecord::Base.send(:include, Touch) -- libgit2 0.21.2