Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cache_with_locale

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache_with_locale

  • 0.0.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status RailsJazz https://www.patreon.com/igorkasyanchuk

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.

This gem also works for collection caching like this:

  = render partial: :post, collection: @posts, cached: true

Usage

Just add this gem to your Gemfile.

Installation

Add this line to your application's Gemfile:

gem 'cache_with_locale'

And then execute:

$ bundle

Contributing

Contributors:

Change Log

0.0.3

0.0.2

0.0.1

  • initial version, ready for production

License

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

FAQs

Package last updated on 17 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc