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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:30:15+00:00 2026-05-21T21:30:15+00:00

This seems like a simple question but I can’t seem to find an answer

  • 0

This seems like a simple question but I can’t seem to find an answer short of writing custom validators. I have this validator

validates :password, :presence => true, :confirmation => true, :length => { :minimum => 5}

there are more rules applied such as some regex for complexity, but this gives the gist.

The issue is that I only want presence applied on create, everything else needs to be on create and update. Because the user may not be changing a password when updating their information.

I tried splitting the rules

validates :password, :presence => true, :on => :create
validates :password, # The rest of the rules

This resulted in all rules being ignored for update. Is there a simple way to apply only one rule to create and the rest to everything?

  • 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-21T21:30:16+00:00Added an answer on May 21, 2026 at 9:30 pm

    You can try keeping it in one line, but applying :on => :create to just the :presence check:

    validates :password, :presence => {:on => :create}, :confirmation => true, :length => { :minimum => 5}
    

    However, I’m not sure it makes sense to always require a minimum length, but not always require presence — if you update an existing record with a blank password, it’s going to fail validations anyway since the length is 0.

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

Sidebar

Related Questions

This seems like a really simple question, but I can't find the answer anywhere.
This should be a fairly simple question to answer. I looked around and couldn't
I've noticed that in functional languages such as Haskell and OCaml you can do
Can you advise on whether I can use just the Query functionality from Lucene
I have a question very similar to How do I allocate a std::string on
I'm trying to use the ddply method to take a dataframe with various info
I am developing a site that encourages other bloggers to take a image and
The Spring BlazeDS integration (in our cases 1.0.5M1) allows us to define MessageInterceptor instances
I have a project I am working on my local computer, and deployed in

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.