David Kimura PRO said over 8 years ago on Fragment Caching :

Check out the show notes for an update to the code. Thank you /u/danshep for pointing this out. https://www.reddit.com/r/ruby/...


brendon said over 8 years ago on Fragment Caching :

Hey this was very interesting to watch :) Just a quick note. There is a more descriptive way to access the previous and current value of an attribute using ActiveModel::Dirty. Basically the current value is easy to get: tag_list. To get what the value was you can just call: tag_list_was. I'm pretty sure you also don't need the self. when referring to the current instance in an instance method. So:


def expire_changed_tags
modified_tags = tag_list_was - tag_list | tag_list - tag_list_was
modified_tags.each do |tag|
expire_fragment "tag/#{tag}"
end
end

David Kimura PRO said over 8 years ago on Fragment Caching :

You are absolutely correct. In the tutorials, I do like indicating self` as it is more clear where we are calling the methods from instead of a separate helper or extension outside of the model we're working with. For anyone who wants to see the available options for ActiveRecord::Dirty be sure to read up on them here http://api.rubyonrails.org/cla....


Login to Comment