Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:36:00+00:00 2026-06-06T01:36:00+00:00

Imagine you have two views with code like the following: controller_a/a.html.erb <%= content_tag(:div) do

  • 0

Imagine you have two views with code like the following:

controller_a/a.html.erb

  <%= content_tag(:div) do %>
     <%= I18n.t "some.key" %>
  <% end %>

controller_b/b.html.erb

  <%= content_tag(:div) do %>
     <%= I18n.t "some.key" %>
  <% end %>

  <%= content_tag(:div) do %>
     <%= I18n.t "some.other_key" %>
  <% end %>

So, a.html.erb is on controller_a#a, while b.html.erb is on controller_b#b. Both actions are cached by caches_action. How can I make sure that when I change the some.key translation key, both views are invalidated? How could I build a generic mechanism?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:36:02+00:00Added an answer on June 6, 2026 at 1:36 am

    Say, in your ApplicationController create the following class-method (or in a lib and extend by it):

    def self.i18n_digest(*scopes)
        Digest::MD5.hexdigest I18n.t(scopes).to_s
    end
    

    Then you can use :cache_path option in your caches_action this way:

    caches_action :some_action, cache_path: { some_key: i18n_digest('some', 'foo') }
    

    Just make sure that you set the locale in a before_filter before this statement.

    Docs on cache_path.

    Note: I’m using the scope of translation ('some') to get all its nested messages as a hash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two partials _choose.html.erb and _details.html.erb. I render choose like so: <div id="choose"
Let's imagine I have two threads which execute some database-oriented code in thread-specific TransactionScopes
Imagine the following situation: I have two branches: DEV and MAIN. I'm working on
I have some data which I am formatting like this: // ... imagine populating
Imagine I have two sites that share basic code. Most of their code matches
Imagine you have two images A and B, and a third grayscale image T.
Imagine we have two tables in the database, user (FK id_role) and role (PK
Imagine I have two protocols: @protocol A @end and @protocol B <A> // Protocol
Imagine you have an entity that has some relations with other entities and you
Imagine I have two (three, four, whatever) tasks that have to run in parallel.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.