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 105 @comment.author = user if logged_in?
106 106 @comment.article = @page
107 107 if @comment.save
108   - @page.touch
  108 + @page.update_attribute(:updated_at, Time.now)
109 109 @comment = nil # clear the comment form
110 110 redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view]
111 111 else
... ...
app/sweepers/article_sweeper.rb
... ... @@ -15,7 +15,7 @@ protected
15 15 def expire_caches(article)
16 16 article.hierarchy.each do |a|
17 17 if a != article
18   - a.touch
  18 + a.update_attribute(:updated_at, Time.now)
19 19 end
20 20 end
21 21 blocks = article.profile.blocks
... ...
vendor/plugins/touch/init.rb
... ... @@ -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)