Skip to content
No description, website, or topics provided.
Ruby HTML CSS JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib use more uniq name to include overides Jun 18, 2018

Build Status

Rails cache with locale

Automatically adding current application locale (I18n.locale) as a part of caching key in Rails views.

Problem & Solution

For example you have:

  • Rails app with different locales
  • you want to add fragment caching in views

When you have a different locales and you adding a caching you writing code like this

  = cache [@user, I18n.locale] do
    = render @user

As you see you need to add I18n.locale as a part of caching key. And you need to do it everywhere. What if you forget about it in some view?

This gem is a simple solution which allows you to DRY your code. So now you can write

  = cache @user do
    = render @user

And let gem handle all work. You don't need to specify locale as a cache sufix/prefix.


Just add this gem to your Gemfile.


Add this line to your application's Gemfile:

gem 'cache_with_locale'

And then execute:

$ bundle


Contribution directions go here.


The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.