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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:37:45+00:00 2026-06-14T23:37:45+00:00

i have followin the http://ruby.railstutorial.org/ class User < ActiveRecord attr_accessible …, :password, :password_confirmation has_secure_password

  • 0

i have followin the http://ruby.railstutorial.org/

class User < ActiveRecord
  attr_accessible ..., :password, :password_confirmation
  has_secure_password

  validates :password, :presence => true,
                       :length => { :minimum => 6 }
  validates :password_confirmation, :presence => true

  ....
end

the problem is to create a new user this works fine, both passwords must be present and they need to match, when i update it requires me to provide the password

for example if another controller wants to change any field of User i must provide a password because otherwise i will not be able to update.

how can i formulate a contition to only require password/password_confirmation when creating the model or doing password update ?

  • 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-14T23:37:46+00:00Added an answer on June 14, 2026 at 11:37 pm

    If you’re using rails3, you can skip validations. From the docs:

    The following methods skip validations, and will save the object to
    the database regardless of its validity. They should be used with
    caution.

    • decrement!
    • decrement_counter
    • increment!
    • increment_counter
    • toggle!
    • touch
    • update_all
    • update_attribute
    • update_column
    • update_counters

    Note that save also has the ability to skip validations if passed :validate => false as argument. This technique should be used with caution.

    Basically, use find to find the appropriate user, update whatever fields you want, user.save!(:validate=>false), and Bob’s your uncle!

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

Sidebar

Related Questions

I have been following this tutorial, http://ruby.railstutorial.org/chapters/modeling-users?version=3.2#top , which I find great, but it
I have been following this tutorial, http://ruby.railstutorial.org/chapters/modeling-users?version=3.2#top , and I tried this in the
I have been following this tutorial, online http://ruby.railstutorial.org/chapters/sign-in-sign-out?version=3.2#top and in part 8.2.3 there is
I am new to Rails & Ruby and have been following the http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and
I am following the Ruby on Rails tutorial by Michael Hartl http://ruby.railstutorial.org/ I installed
I'm new to rails and working my way into the tutorial here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book I've
I am following the Ruby on Rails Tutorial (http://ruby.railstutorial.org) . In Chapter 3, the
I am following the Ruby on Rails Tutorial for Rails 3, located here: http://ruby.railstutorial.org
Studying at http://ruby.railstutorial.org/ version 3.2 Stucked in the end of 6.2.1 section with the
I was reading through rails tutorial (http://ruby.railstutorial.org/book/ruby-on-rails-tutorial#sidebar-database_indices) but confused about the explanation of database

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.