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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:53+00:00 2026-05-31T13:11:53+00:00

In an multilingual application, a user can input their Chinese and English names. The

  • 0

In an multilingual application, a user can input their Chinese and English names. The user can input either or both, but must input at least one name.

class Person < ActiveRecord::Base
  validates :zh_name, :presence => true
  validates :en_name, :presence => true
  validates :fr_name, :presence => true
end

Since the built-in :validates_presence_of method can only validate both attributes at once, is there a way to validate the presence of at least one of many attributes in rails?

Like a magical, validates_one_of :zh_name, :en_name, :fr_name

Thank you in advance,

  • 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-31T13:11:54+00:00Added an answer on May 31, 2026 at 1:11 pm
    validate :at_least_one_name
    
    def at_least_one_name
      if [self.zh_name, self.en_name, self.fr_name].reject(&:blank?).size == 0
        errors[:base] << ("Please choose at least one name - any language will do.")
      end
    end      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php Web Application Multilingual, I have a php variable which can
i am so much eager to develop the multilingual application. But i don't know
I am developing an multilingual application using Django. One part is to select the
Possible Duplicate: How can I create a multilingual android application? I am creating application
I plan develop one web application with PSGI/Plack. (probaly with Dancer, but not decided
Building a multilingual application that should work with the most prevalent global alphabets but
I am attempting to write a multilingual application in Silverlight 4.0 and I at
We are developing a multilingual Winforms application using visual studio 2008. I am trying
I am developing a multilingual web application that has a nice looking UI. I
I am working on a multilingual web application. I'm wondering how do i design

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.