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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:15:32+00:00 2026-06-15T05:15:32+00:00

I have followed Railscast episode 250 revised to create user authentication with has_secure_password which

  • 0

I have followed Railscast episode 250 revised to create user authentication with has_secure_password which works well. However when I try to update the user profile, I obviously run into issues because it requires password and password confirmation to be present.

Obviously there is no way to overwrite this out of the box so I have created a file called secure_password.rb which I have put into my config/initializers folder and copied the content of the pre-existing file.

My question is this – is there any way to pass a conditional to this file to say if controller action update/edit then don’t require password and password confirmation to be present?

My current code can be found below.

  def has_secure_password
    gem 'bcrypt-ruby', '~> 3.0.0'
    require 'bcrypt'

    attr_reader :password

    validates_confirmation_of :password
    validates_presence_of     :password_digest

    include InstanceMethodsOnActivation

    if respond_to?(:attributes_protected_by_default)
      def self.attributes_protected_by_default
        super + ['password_digest']
      end
    end
  end
  • 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-15T05:15:33+00:00Added an answer on June 15, 2026 at 5:15 am

    when password_confirmation is explicitly set to nil, the confirmation validation will not be checked. This is refered to in a Rails pull-request, which suggests having some conditional value to decide if password_confirmation should be required.

    In Railscasts #250, I would simply remove the password_confirmation-field, and change the create-action in the Users-controller to the following:

    def create
      @user = User.new(params[:user])
      @user.password_confirmation = nil  # Disables confirmation check
      if @user.save
        redirect_to root_url, :notice => "Signed up!"
      else
        render "new"
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed RailsCasts authentication from scratch (http://railscasts.com/episodes/250-authentication-from-scratch-revised) using the bcrypt-ruby gem and have the
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have followed thenewbostons java game tutorials on youtube and managed to create a
I have followed the following railscast about adding pdfkit to an application, and I
I have followed the Railcast #270 has_secure_password tutorial and have that all working. For
i have followed the railscasts episode on nested forms(part 1 and 2) and having
I am trying to create profile pages for my community site. I have followed
I have followed the omniauth devise facebook app as explained by Ryan in episode
I'm following railscast and have followed the instructions exactly. I've even used net.tutsplus's faye.ru
I've read that others have followed the Endless Page railscast and modified it to

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.