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 6349589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:38:46+00:00 2026-05-24T21:38:46+00:00

I can localize an error message for each validation, but how can I create

  • 0

I can localize an error message for each validation, but how can I create an error for particular model.

Ordinary locale looks like this:

en:
  mongoid:
    errors:
      messages:
        taken: "It is already taken"

But I want to change message for user model:

en:
  mongoid:
    errors:
      messages:
        taken: "It is already taken"
        user:
          taken: "It is already taken. %{link_to 'Remember password', reset_password_path'}"
  • 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-05-24T21:38:47+00:00Added an answer on May 24, 2026 at 9:38 pm

    Try this:

    en:
      mongoid:
        errors:
          messages:
            taken: "It is already taken"
          models:
            user:
              attributes:
                login:
                  taken: "It is already taken. %{link}"
    

    Reference:

    ActiveRecord code comments

    PS:
    The localization string should use interpolation variable for dynamic substitution.

    E.g:
    Add an error on the login field of user object:

    user.errors.add(:login, :taken, :link => "foo")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me how I can display a status message like 12 seconds
I try to localize error messages from the Domain classes. This is possible with
I nearly got my validation message localized as you can see it works for
I try to figure out how I can localize the error item name in
How can I localize strings in cakePhp? I havent had any success with the
I'd like to get the message number and severity level information from SQL Server
The following example is clearly fictional but it resumes how validation is done on
As part of some error handling in our product, we'd like to dump some
I've managed to mostly ignore all this multi-byte character stuff, but now I need
Heey, I can localize my iPhone app with the systems local by localizing the

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.