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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:30:00+00:00 2026-05-27T04:30:00+00:00

I want to update/edit a devise user from my own form in my project,

  • 0

I want to update/edit a devise user from my own form in my project, but the problem is that I can’t redirect on update on the “request.referer”.

I’ve read that but it didn’t work for me: https://github.com/plataformatec/devise/wiki/How-To:-Customize-the-redirect-after-a-user-edits-their-profile
…And the others wiki pages.

Okay, so my code is:

#/views/backend/perso.html.erb
<%= form_for(@user, :url => registration_path(@user), :html => { :method => :put }) do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(form.errors.count, "error") %> prohibited this data from being saved:</h2>

      <ul>
      <% @user.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
# Other fields ...
  <div class="field">
    <%= f.label :email %><br />
    <%= f.email_field :email %>
  </div>

  <div class="field">
    <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
    <%= f.password_field :current_password %>
  </div>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

So the user is on that page, and updates his data. Problem, I get redirected to /users/
I’ve tried to add that to routes:

#config/routes.rb
devise_for :users do
    get "users", :to => "backend#perso", :as => :user_root # Rails 3
end

Or even to the application controller:

#/controllers/application_controller.rb
private
def after_update_path_for(resource)
  backend_perso_path
end

But still not working.

Thanks for anyone trying to help me out !

Edit

When the update generates no error, I get redirected to the page I want (by adding after_update_path_for in my application controller), but when errors exist, it displays /view/devise/registration/edit.html.erb

Update

Ok, so I overwrited the Devise controller following that:
https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-edit-their-account-without-providing-a-password

So my code in registrations_controller looks like that

#controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
  def update
    # Devise use update_with_password instead of update_attributes.
    # This is the only change we make.
    if resource.update_attributes(params[resource_name])
      set_flash_message :notice, :updated
      # Line below required if using Devise >= 1.2.0
      sign_in resource_name, resource, :bypass => true
      redirect_to after_update_path_for(resource)
    else
      clean_up_passwords(resource)
      redirect_to backend_perso_path # That's the line I need to change
    end
  end
end

I can now redirect to the page I wanted, but I don’t know how to show that errors happened !

  • 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-27T04:30:01+00:00Added an answer on May 27, 2026 at 4:30 am

    simple answer via Rails Routing from the Outside In using the “not quite as elegant” hardcoded user_root as described in How To: Customize the redirect after a user edits their profile

    #config/routes.rb
    match 'user_root' => redirect("/wherever/you/want")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dynamically I want to edit/update hosts(etc/hosts) file to add domain. To edit hosts(etc/hosts) file
What I want: Update all new commits from server with my local repository in
I want to update a list of storage devices as the user inserts USB
i want to update my sqlite database but i cannot find the way to
I want to use this function from mongoid: person.update_attributes(first_name: Jean, last_name: Zorg) But I
I want to update a progress bar from running 1 to 100 with this
I want to update a huge text file in UITextView. But the device just
I want to update a table but the update SQL is not performed so
I'm using Devise in a Rails 3 app, but in this case, a user
I want to update data in a database, in page update that is, adding

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.