Last active
May 31, 2016 11:39
-
-
Save norman/b769b528e003da569968a9b2c4cf889c to your computer and use it in GitHub Desktop.
One way to make Rails consider the layout in an etag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By default, changes to the layout temnplate won't cause a Rails etag | |
# to change. I suppose this is to facilitate Turbolinks. Sometimes you | |
# might want to change an etag in response to changes in the layout - | |
# this is particularly true when working in development mode. This is | |
# one way to do it, there are probably other (read: likely better) ways | |
# to do this too. | |
class FooController < ApplicationController | |
# There's probably some API method to get the name of the layout | |
# rather than hard-coding it like I did here, but I'm too lazy to | |
# look it up right now. | |
etag { | |
ActionView::Digestor.digest(name: "layouts/application.html.erb", finder: view_context.lookup_context) | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment