28 Aug '15, 10am

ruby: Railsアプリを66%スピードアップ ― Railsキャッシュの完全ガイド | プログラミング | POSTD

class Corporation < ActiveRecord::Base has_many :cars end class Car < ActiveRecord::Base belongs_to :corporation, touch: true end class Brake < ActiveRecord::Base belongs_to :car, touch: true end @brake = Brake.first # calls the touch method on @brake, @brake.car, and @brake.car.corporation. # @brake.updated_at, @brake.car.updated_at and @brake.car.corporation.updated_at # will all be equal. @brake.touch # changes updated_at on @brake and saves as usual. # @brake.car and @brake.car.corporation get "touch"ed just like above. @brake.save @brake.car.touch # @brake is not touched. @brake.car.corporation is touched.

Full article: http://postd.cc/the-complete-guide-to-rails-caching/

Tweets