Skip to content

Instantly share code, notes, and snippets.

@mipearson
Created June 1, 2018 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mipearson/4f5feefb87f5f4156743133180ab97a4 to your computer and use it in GitHub Desktop.
Save mipearson/4f5feefb87f5f4156743133180ab97a4 to your computer and use it in GitHub Desktop.
Rails development speedups
# include this mixin (or put the code directly) into your application_controller.rb
module Shared
module DevelopmentViewResolveCaching
extend ActiveSupport::Concern
# Speeds up development view rendering by about ~300ms as we don't need
# to call the slow view resolver more than once per partial.
#
# From https://github.com/rails/rails/issues/20752
included do
if Rails.env.development?
prepend_before_action { ActionView::Resolver.caching = true }
after_action { ActionView::Resolver.caching = false }
end
end
end
end
# Put this in config/initializers, customise to your own needs
# Unregistering these unused handlers speeds up view template resolution.
ActionView::Template.unregister_template_handler(:raw, :ruby, :coffee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment