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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:34:15+00:00 2026-05-23T09:34:15+00:00

I think this question might have been asked before, but I honestly don’t know

  • 0

I think this question might have been asked before, but I honestly don’t know how to search for it.

Basically, when I do a render :action => ‘edit’ in the update action in controller, somehow the view outputs the form as if it’s a :action => ‘new’ page.

form_for gave the wrong action and f.submit gave wrong button text (it gave create instead of update)

edit:

relevant parts of controller

def edit
  @user = User.find_by_email(current_user.email)
end

def update
  old_password=params[:user].delete(:old_password)
  @user=User.new(params[:user])

  if User.find_by_email(@user.email).valid_password?(old_password)
    logger.info 'Valid old password'
  else
    flash[:notice]='Invalid current password'
    render :action=>'edit'
  end
end
  • 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-23T09:34:15+00:00Added an answer on May 23, 2026 at 9:34 am

    As discussed in the comments, @bassneck is right – while you are rendering the edit view, the form_for call looks at whether the object is persisted or not (@user.persisted?). This has the benefit in a lot of cases of being able to use one piece of form code for both new and edit views (I’ll generally have a partial _form.html.erb that gets used for both situations).

    In your case though, it isn’t leading to the desired behaviour – so wwhat you need to do is make sure you’re using the relevant user object. If you want to update a user, @user should be the object you want to update.

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

Sidebar

Related Questions

I don't think this question has been asked before. I'm a bit confused on
Now I know this basic question has been asked before, but I must be
I know this question has been asked a bit before. But looking around I
I know this type of question has been asked before, but I could not
I think this question has been asked many a times but I've been searching
i know this question has been asked here but i am stuck with this
I know questions like this have been asked before, and I've viewed a lot
This is a question which has been asked before ( large-text-and-images-in-sql ) but mainly
I mostly develop using C#, but I think this question might be suitable for
Firstly, This might seem like a long question. I don't think it is... The

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.