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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:30:49+00:00 2026-06-17T06:30:49+00:00

My User model is using has_secure_password (based on the Rails tutorial Book ): schema.rb:

  • 0

My User model is using has_secure_password (based on the Rails tutorial Book):

schema.rb:

create_table "users", :force => true do |t|
  t.string   "password_digest"
end

user.rb:

class User < ActiveRecord::Base
  attr_accessible :name, :email, :avatar, :password, :password_confirmation, :provider, :uid

  has_secure_password

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

And I have this edit view:

<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :email %>
<%= f.text_field :email %>

<%= f.label :password %>
<%= f.password_field :password %>

<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>

<%= f.label :avatar %>
<%= f.file_field :avatar %>

Now the problem is that the user has to fill the password and password_confirmation field each time he/she wants to update the other fields.

So I was thinking of dividing the form:

users/edit.html.erb:

<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :email %>
<%= f.text_field :email %>

<%= f.label :avatar %>
<%= f.file_field :avatar %>

users/edit_password:

(I will add a current_password field later here).

<%= f.label :password, "New Password" %>
<%= f.password_field :password,  %>

<%= f.label :password_confirmation, "Confirm Password", "Retype Password" %>
<%= f.password_field :password_confirmation %>

I’m thinking of two options:

  1. Having all the user fields in each view, but making those fields I don’t want the user to see hidden fields (the problem is that I can’t retrieve the password for some reason. Something like @user.password returns nil. I can only do @user.password_digest but that won’t validate the field).
  2. Adding :unless in the password and password_confirmation validation (but I’m not sure how to do it so that it only applies to the users/edit view).

What’s the best solution here?

  • 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-17T06:30:51+00:00Added an answer on June 17, 2026 at 6:30 am

    You cannot get user’s password since the DB does not store it (it stores one-way encrypted password digest). So the second option is correct.

    Take a look at Devise implementation (validation and controller), it can help.

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

Sidebar

Related Questions

I am somewhat new to Rails and working on designing a User model using
I'm using Paperclip to save pictures in my Rails application: User model: class User
My user model has three relations for the same message model, and is using
I have a simple User model which is associated to many Town objects using
I'm creating a registration form using validation inside the User model such as validates_confirmation_of
I'm using CanCan for authorization. I define the model-action-user rules in /app/config/ability.rb and it's
I'm using a modelform for User like so: class UserForm(forms.ModelForm): class Meta: model =
I am using EntityFramework 4.1. I have the following model: public class User {
I am using Rails 3.2. I have following models: Blog Comment User class Blog
I'm using Rails 3 with Devise for user auth. Let's say I have a

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.