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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:53:04+00:00 2026-05-18T01:53:04+00:00

When a user registers, if there is an error, after submitting the page refreshes

  • 0

When a user registers, if there is an error, after submitting the page refreshes and you see the error message about why the form wasn’t submitted to the DB.

But in this form, the values from the orig form are gone, yet they seem to be in memory bec if you click refresh you can resubmit, so the values are there.

Why isn’t rails showing the previously inputted values, allowing the user to update an resubmit?

My form for devise new.html.erb

    <%= form_tag(user_registration_path, :method=>'post', :id => 'user_new') do |f| %>
.
.

        <tr>
            <td class="label">
                <%= label_tag 'password', 'Password:', :id => 'lpassword', :for => 'password' %>
            </td>
            <td class="field">
                <%= password_field_tag 'user[password]', nil, :id => 'user[password]', :maxlength => 50 %>
            </td>
            <td class="status"></td>
        </tr>

        <tr>
            <td class="label">
                <%= label_tag 'user[email]', 'Email Address:', :id => 'luser[email]', :for => 'user[email]' %>
            </td>
            <td class="field">
                <%= text_field_tag 'user[email]', nil, :id => 'user[email]', :maxlength => 150 %>
            </td>
            <td class="status"></td>
        </tr>
        <tr>
            <td class="label"><label id="lsignupsubmit" for="signupsubmit"> </label></td>
            <td class="field" colspan="2">
                <input id="signupsubmit" name="signup" type="submit" value="Sign Up" />
            </td>
        </tr>
    </table>

    <% 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-18T01:53:05+00:00Added an answer on May 18, 2026 at 1:53 am

    The usual flow that handles this works like this:

    #users_controller.rb
    def new
      @user = User.new
    end
    
    def create
      begin
        @user = User.create!(params[:user])
      rescue ActiveRecord::RecordInvalid => e
        flash[:error] = e.record.errors.full_messages.to_sentence
        render :action => "new"
      end
    end
    

    then

    #views/users/new.html.erb
    <%= form_for(@user, :url => user_registration_path, :method=>'post', :id => 'user_new') do |f| %>
      <%= f.label :password %>
      <%= f.password_field %>
    
      <%= f.text_field :email %>
      # etc...
    <% end %>
    

    The difference here is using form_for which takes a record, and using the slightly different f.text_field :email instead of text_field_tag helpers which automatically sets the field value to @user.email. There’s a slightly different number of parameters, since you don’t need to tell those helpers what the field value should be, so check the docs on them.

    When the validation is hit, since the render is being called, and not redirect, the invalid @user object is still populated with the originally posted values, hence inserting them into the field.

    I’m not entirely sure what devise does in it’s internals, but this sort of best practices approach, should send you on the right way.

    A not so clean alternative would be to set the values in the field from the params hash like so:
    <%= text_field_tag('user[email]', (params[:user] ? params[:user][:email] : nil), :id => 'user-email', :maxlength => 150 %>. This method also assumes that a render, and not a redirect happens when an invalid form is posted (or that the params are sent through again in the redirect).

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

Sidebar

Related Questions

I have a login.jsp page which contains a login form. Once logged in the
This is beyond both making sense and my control. That being said here is

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.