No commit activity in last 3 years
No release in over 3 years
Rails fragment caching from within mailers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.3
~> 1.3

Runtime

< 5.0, >= 3.0
 Project Readme

Mailer Fragment Caching

Allows the use of Rails fragment caching helpers from within mailers.

Tested in Rails 3.2, 4.0, 4.1 and 4.2. If you're using Rails 5 then you don't need this gem as this feature has now been added to Rails 5.

Installation

Add this line to your application's Gemfile:

gem 'mailer_fragment_caching'

And then execute:

$ bundle

Make sure you have caching enabled in your environment configuration:

config.action_controller.perform_caching = true

And configure your cache store as your please:

config.cache_store = :mem_cache_store

Usage

Include the module within your mailer file.

class CoolMailer < ActionMailer::Base

  include MailerFragmentCaching

  def cool_email
    ...
  end

end

Use cached fragments in your mailer templates, just like regular views.

<% cache @thing do %>
  <%= render @thing %>
<% end %>