Skip to content

Commit

Permalink
Include cache key in ModelName
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Jun 25, 2008
1 parent 6874caa commit 071fe79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -2170,11 +2170,11 @@ def to_param
def cache_key def cache_key
case case
when new_record? when new_record?
"#{self.class.name.tableize}/new" "#{self.class.model_name.cache_key}/new"
when self[:updated_at] when timestamp = self[:updated_at]
"#{self.class.name.tableize}/#{id}-#{updated_at.to_s(:number)}" "#{self.class.model_name.cache_key}/#{id}-#{timestamp.to_s(:number)}"
else else
"#{self.class.name.tableize}/#{id}" "#{self.class.model_name.cache_key}/#{id}"
end end
end end


Expand Down
@@ -1,12 +1,13 @@
module ActiveSupport module ActiveSupport
class ModelName < String class ModelName < String
attr_reader :singular, :plural, :partial_path attr_reader :singular, :plural, :cache_key, :partial_path


def initialize(name) def initialize(name)
super super
@singular = underscore.tr('/', '_').freeze @singular = underscore.tr('/', '_').freeze
@plural = @singular.pluralize.freeze @plural = @singular.pluralize.freeze
@partial_path = "#{tableize}/#{demodulize.underscore}".freeze @cache_key = tableize
@partial_path = "#{@cache_key}/#{demodulize.underscore}".freeze
end end
end end


Expand Down

0 comments on commit 071fe79

Please sign in to comment.