Permalink
Browse files

Revert "Added ActiveRecord::Base#last_modified to work with the new f…

…resh_when/stale? conditional get methods from Action Pack"

Needless indirection with no added value.

This reverts commit 535853e.
  • Loading branch information...
1 parent 535853e commit 83d29a283ceb13ff431da535e8cc35db6828016c @dhh dhh committed Dec 1, 2011
@@ -23,7 +23,7 @@ module ConditionalGet
# This will render the show template if the request isn't sending a matching etag or
# If-Modified-Since header and just a <tt>304 Not Modified</tt> response if there's a match.
#
- # You can also just pass a record where last_modified will be set by calling last_modified and the etag by passing the object itself. Example:
+ # You can also just pass a record where last_modified will be set by calling updated_at and the etag by passing the object itself. Example:
#
# def show
# @article = Article.find(params[:id])
@@ -42,7 +42,7 @@ def fresh_when(record_or_options, additional_options = {})
options.assert_valid_keys(:etag, :last_modified, :public)
else
record = record_or_options
- options = { :etag => record, :last_modified => record.try(:last_modified) }.merge(additional_options)
+ options = { :etag => record, :last_modified => record.try(:updated_at) }.merge(additional_options)
end
response.etag = options[:etag] if options[:etag]
@@ -51,7 +51,7 @@ def conditional_hello
end
def conditional_hello_with_record
- record = Struct.new(:last_modified, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123")
+ record = Struct.new(:updated_at, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123")
if stale?(record)
render :action => 'hello_world'
@@ -65,7 +65,7 @@ def conditional_hello_with_public_header
end
def conditional_hello_with_public_header_with_record
- record = Struct.new(:last_modified, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123")
+ record = Struct.new(:updated_at, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123")
if stale?(record, :public => true)
render :action => 'hello_world'
@@ -1,6 +1,5 @@
## Rails 3.2.0 (unreleased) ##
-* Added ActiveRecord::Base#last_modified to work with the new fresh_when/stale? conditional get methods from Action Pack *DHH*
* Implemented ActiveRecord::Relation#pluck method
@@ -1702,13 +1702,6 @@ def cache_key
end
end
- # By default returns the value of the updated_at attribute, but can be overwritten to
- # provide another indicator of when this record was last updated. This is used by
- # ActionControllers conditional get fresh_when/stale? methods.
- def last_modified
- self[:updated_at]
- end
-
def quoted_id #:nodoc:
quote_value(id, column_for_attribute(self.class.primary_key))
end

0 comments on commit 83d29a2

Please sign in to comment.