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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:31:17+00:00 2026-05-25T00:31:17+00:00

I’m Using Devise in my Rails 3.0.9 application for User Authentication. As I wanted

  • 0

I’m Using Devise in my Rails 3.0.9 application for User Authentication. As I wanted to be able to manage Users, I created the following Users Controllers:

class UsersController < ApplicationController
  
  def index
     @users = User.all
   end

   def new
     @user = User.new
   end

   def create
     @user = User.new(params[:user])
     if @user.save
       flash[:notice] = "Successfully created User." 
       redirect_to users_path
     else
       render :action => 'new'
     end
   end

   def edit
     @user = User.find(params[:id])
   end

   def update
     @user = User.find(params[:id])
     params[:user].delete(:password) if params[:user][:password].blank?
     params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
     if @user.update_attributes(params[:user])
       if current_user.update_with_password(params[:user])
           sign_in(current_user, :bypass => true)
       end
       flash[:notice] = "Successfully updated User."
       redirect_to users_path
     else
       render :action => 'edit'
     end
   end

   def destroy
     @user = User.find(params[:id])
     if @user.destroy
       flash[:notice] = "Successfully deleted User."
       redirect_to users_path
     end
   end
  
end

I this works for showing, creating and deleting Users, but I have run into a problem when updating the passwords.

When I Update the password for the currently logged in account it automatically logs me out.

In the controller I tried to fix this using: (you can see it in the code above)

if current_user.update_with_password(params[:user])
   sign_in(current_user, :bypass => true)
end

But that gives me this error ->

undefined method `update_with_password' for nil:NilClass 

What I’m really looking for, is the ability to update any accounts password, without logging them out ( as admins have ability to change regular users password ).

  • 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-25T00:31:17+00:00Added an answer on May 25, 2026 at 12:31 am

    It is not necessary to write

    This code in the controller

    if current_user.update_with_password(params[:user])
      sign_in(current_user, :bypass => true)
    end
    

    Instead you should go ahead with below one

    if @user.update_attributes(params[:user])
       sign_in(current_user, :bypass => true)
       redirect_to users_path
    end
    

    cheers 🙂

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need to clean up various Word 'smart' characters in user input, including but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.