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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:56:49+00:00 2026-05-28T02:56:49+00:00

I am working on a ROR app, and I’m stuck when it comes to

  • 0

I am working on a ROR app, and I’m stuck when it comes to Devise and password confirmation. I’d like for my users to be able to edit their information (name, location, etc) without having to enter and confirm their password (that is unless they decide to change their password, in which case, these fields would be required.)

I did a bit of reading when it comes to devise and I noticed that this is a common issue. Unfortunately, I tried all of the solutions posted on the devise GitHub repo, but was unable to address my issue.

I have however, discovered a workaround, but am having an issue with what I hope will be the final step. Here is a small snippet of what my players.rb file looks like (I have two set’s of accounts — players and owners):

 has_one :account, :as => :profile

 accepts_nested_attributes_for :account, :reject_if => proc { |attributes| attributes['password'].blank? }

my accounts.rb file looks like this:

  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :invited_by, :invited_by_id

As it’s set up right now, the players can edit their profile without having to enter a password unless they are trying to edit the :password field — this is excellent, and my desired result. However, I am running into a small snag… the :reject_if => proc { |attributes| attributes['password'].blank? } executes even when there is a new account (player) being created! This means if a player does not enter a password, instead of prompting him to enter a password, the application brakes!

I need some help writing an if statement or some condition that would basically only trigger the reject_if conditions if the Account belongs to a registered (existing) player.

I have tried: :reject_if => proc { |attributes| attributes['password'].blank? unless Player.new}

and

if Player.new
accepts_nested_attributes_for :account
else
accepts_nested_attributes_for :account, :reject_if => proc { |attributes| attributes['password'].blank? }
end

I cant seem to figure this out, so I decided to see if anyone could offer an opinion or advice. As always, I am extremely grateful for your time and any help you may offer. Thank you!

  • 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-28T02:56:50+00:00Added an answer on May 28, 2026 at 2:56 am

    Try this peace of code while updating user in controller. This is update method for devise version 1.5.3, these two lines will do the trick.

     def update
        self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
    
        params[:user].delete(:password) if params[:user][:password].blank?
        params[:user].delete(:password_confirmation) if params[:user][:password_confirmation].blank?
    
        if resource.update_attributes(params[resource_name]) 
          set_flash_message :notice, :updated if is_navigational_format?
          sign_in resource_name, resource, :bypass => true
          respond_with resource, :location => after_update_path_for(resource)
        else
          clean_up_passwords(resource)
          respond_with_navigational(resource){ render_with_scope :edit }
        end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a RoR app, but this is a general question of strategy
I had a RoR app working fun under Fedora14, I upgraded to Fedora16 and
I'm trying to deploy my RoR app. It seems to be working fine on
I've recently started working with RoR for some projects and I quite like the
I have a really simple app I've built using RoR but I'm stuck modifying
Very new to RoR and am working on a music app where a release
I am working on a RoR website and would like to handle server errors
I'm learning RoR and working on a simple app to share posts. My trouble
I use authlogic in my RoR app. For login, I use email and password
I'm trying to get a simple search form working in my RoR site. I've

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.