user = User.find_by(name: 'Phusion')
user_path(user) # => "/users/1"
class User < ActiveRecord::Base
def to_param # overridden
name
end
end
user = User.find_by(name: 'Phusion')
user_path(user) # => "/users/Phusion"
Product.new.cache_key # => "products/new"
Product.find(5).cache_key # => "products/5" (updated_at not available)
Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available)
Person.find(5).cache_key(:updated_at, :last_reviewed_at)
class User < ActiveRecord::Base
to_param :name
end
user = User.find_by(name: 'Fancy Pants')
user.id # => 123
user_path(user) # => "/users/123-fancy-pants"