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

  • SEARCH
  • Home
  • 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 7853451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:41:53+00:00 2026-06-02T19:41:53+00:00

I know that model should not be aware of session data but I have

  • 0

I know that model should not be aware of session data but I have a need to access a small bit of state information in the method_missing that is defined on a model. Methods caught by method_missing are invoked by form helpers, i.e.:

client_medias/new.haml:
    f.text_field :new_display_name

client_media.rb:
    has_many :custom_properties, :as => :extensible

Here ‘new_display_name’ is a custom property key defined through a polymorphic association. I need to know the context (in my case provided by current_app method accessible in the controller) to get the collection of distinct custom property keys which I am mapping to the dynamic method definitions in method_missing.

Any ideas? I looked into Thread.current and am inclined to use it at this moment.

  • 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-02T19:41:55+00:00Added an answer on June 2, 2026 at 7:41 pm

    we have a similar problem, where we are handling multiple mandants in a single application. in our case, the context is the mandant, that is identified through the toplevel-domain the user loads the site from.

    our approach is to use the logic within I18n to provide a “singleton” that we can access within every part of our application, like it’s done with I18n.locale which uses Thread.current too.

    we then set up the singleton in our application controller as a before filter, so that every other part of the application can use it within the same response.

    as a starting point have a look at sven fuchs implementation https://github.com/svenfuchs/i18n/blob/master/lib/i18n.rb

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

Sidebar

Related Questions

I know that component-model indicates whether a property has a default value or not,
I know that I should put all the html elements in body tag, but
I know that you should extend Model to get all the jpa functionality. However,
I know similar questions have been posed before, but I could not find a
tl;dr-edition: I have a compilation I know that will fail, but want the subset
In the parent delegation model for loading classes, I know that loadclass() is invoked
I know that g.setXORMode(Color c) enables XOR mode drawing. But how to disable this
I know that it's a subject that can raise a lot of debate, but
I know that exceptions have a performance penalty, and that it's generally more efficient
We know that it is not possible to execute code that manipulates the properties

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.