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

  • Home
  • SEARCH
  • 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 3602836
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:47:48+00:00 2026-05-18T20:47:48+00:00

I am using rails and devise. It seams the only way to update a

  • 0

I am using rails and devise. It seams the only way to update a user object is to go through the form. Even when I use console or save(false) the devise objects doesn’t seem to be working.

I don’t want to display the new and confirm password unless a user clicks a link that says change password. This then changes a boolean on the user to true, and redirects to the user page and then an if/else/end shows the appropiate code.

The problem is that the first change_password does get set, but the second will not change it back. Crazy.

model

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

 # Setup accessible (or protected) attributes for your model
 attr_accessible :email, :password, :password_confirmation, :name, :change_password

 has_many :analytics
 has_many :answers

 before_save :change_password_to_false


 def change_password_to_false
   self.change_password = false
 end

controller

def change_password
  player = Player.find(current_player.id)
  player.change_password = true
  player.save(false)    
  redirect_to edit_player_registration_path 
end

def keep_password_the_same
  player = Player.find(current_player.id)
  player.change_password = false
  player.save(false)    
  redirect_to edit_player_registration_path
end

view

<% if current_player.change_password?  %>
    <h4><%= link_to "Keep Password The Same", keep_password_the_same_path  %></h4>
    <%= render 'change_password', :f => f %>
<% else %>
    <h4><%= link_to "Change Password", change_password_path  %></h4>
<% end %>

Update

There were a few problems with the code but codevoice was able to get me in the right direction. I thought save(false) was bypassing callbacks too but that was not the case. So every time the user was updated even when the user was updated with save(false) it change_password was getting set to false.

The second thing was giving the user the ability to remove the change password fields if they decided they didn’t want to change it. So in the callback I just check if the change_password field was just changed to true and then I don’t do anything. If the password was already true and the user was just updated then you can reset it to false.

  • 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-18T20:47:49+00:00Added an answer on May 18, 2026 at 8:47 pm

    in my opinion your change_pasword attribute will be alweys false beacasue you use before_save :change_password_to_false. Thats mean that you are changeing change_password to false every time you save the Player model

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

Sidebar

Related Questions

No related questions found

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.