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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:05:29+00:00 2026-05-28T01:05:29+00:00

according to rails’ built-in validation functions, what is the difference between these following two

  • 0

according to rails’ built-in validation functions, what is the difference between these following two methods?

validates :password, :confirmation =>true

and

validates_confirmation_of :password

as far as I understand, the first was just introduced in rails version 3?
am I correct?

  • 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-28T01:05:30+00:00Added an answer on May 28, 2026 at 1:05 am

    They both do the same exact thing, validates_confirmation_of is just one of the many short form helper methods for validates.

    If you look at the source, you can see that the validates method is just written to handle all validators whereas validates_confirmation_of explicitly uses the ConfirmationValidator

    I think validates_confirmation_of was introduced in Rails 2 so it’s been around for quite a while.

    Source comparison:

      def validates_confirmation_of(*attr_names)
        validates_with ConfirmationValidator, _merge_attributes(attr_names)
      end
    

    and

      def validates(*attributes)
        defaults = attributes.extract_options!
        validations = defaults.slice!(*_validates_default_keys)
    
        raise ArgumentError, "You need to supply at least one attribute" if attributes.empty?
        raise ArgumentError, "You need to supply at least one validation" if validations.empty?
    
        defaults.merge!(:attributes => attributes)
    
        validations.each do |key, options|
          # LOOK AT THIS LINE
          key = "#{key.to_s.camelize}Validator"
    
          begin
            validator = key.include?('::') ? key.constantize : const_get(key)
          rescue NameError
            raise ArgumentError, "Unknown validator: '#{key}'"
          end
    
          # AND LOOK AT THIS LINE
          validates_with(validator, defaults.merge(_parse_validates_options(options)))
        end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

according to this (older) post these Rails 3 finders have race conditions. Something like
According to what I have found so far, I can use the following code:
My rails app, according to my heroku logs, is serving requests on average of
I have Rails polymorphic model and I want to apply different validations according to
I'm using gem rapns (https://github.com/ileitch/rapns) on my rails app. According to rapns doc, I
I'm new to cakephp. I'm using the 2.0.5 release, according it looks like rails
According to the Ruby on Rails 2.3 Release Notes... if your plugin has an
I am following the Ruby on Rails Tutorial (http://ruby.railstutorial.org) . In Chapter 3, the
I understand that according to Rails philosophy, data integrity checks should be done at
According to this Rails guide , if you create a fixture, it becomes available

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.