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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:22:08+00:00 2026-06-11T10:22:08+00:00

I have a page that lets an admin user register a new user, by

  • 0

I have a page that lets an admin user register a new user, by entering details into a form.

<%= stylesheet_link_tag "signup" %>


<%= form_for(@user) do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

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

<div class="signup">
  <div class = "field">Username:  
  <%= f.text_field :username, :class => "username"  %></div>

</br>
  <div class = "field">Email:  
  <%= f.email_field :email, :class => "email"  %></div>

</br>
    <div class = "field">First Name:  
  <%= f.text_field :firstname, :class => "firstname"  %></div>

</br>
<div class = "field">Last Name:  
  <%= f.text_field :lastname, :class => "lastname"  %></div>

</br>

<div class="field">
    <%= f.label :admin %><br />
    <%= f.text_field :admin, :class => "admin" %>
  </div>

<div class = "field">
  <div class="actions">
    <%= f.submit "Register New User", :class => "button" %>
  </div>
</div>
</div>
<% end %>

here is the new and create actions from the admin_controller:

def create

    @user = User.new(params[:user])
if @user.save


    respond_to do |format|

        format.html { redirect_to @user, notice: 'User was successfully created.' }
        format.json { render json: @user, status: :created, location: @user }
end
      else
respond_to do |format|
        format.html { render action: "new" }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

def new
    @user = User.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @user }
    end
  end

Once the form is filled in, and I hit register new user, I get brought back to the home page, and the data does not go into the database.

EDIT: full log after clicking register new user
I can see that the data in the logs:

    Started POST "/users" for 127.0.0.1 at 2012-09-17 12:27:49 +0100
Processing by Devise::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"Bhh2ELWIFW9bENXeQ3Yta+bJqD7Dx8os9zdvnN0m5sM=", "user"=>{"username"=>"test", "email"=>"test@test.com", "firstname"=>"test", "lastname"=>"test", "admin"=>"false"}, "commit"=>"Register New User"}
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.2ms)


Started GET "/" for 127.0.0.1 at 2012-09-17 12:27:49 +0100
Processing by ProjectsController#index as HTML
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  Project Load (0.2ms)  SELECT "projects".* FROM "projects" 
  Rendered projects/index.html.erb within layouts/application (1.0ms)
Completed 200 OK in 5ms (Views: 4.0ms | ActiveRecord: 0.4ms)

I am new to rails so please remember this when trying to help. Thanks in advance

  • 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-06-11T10:22:09+00:00Added an answer on June 11, 2026 at 10:22 am

    You are simply not saving the user to the DB and are calling the wrong controller action.

    First: The way this works in Rails is that usually new action renders the form to the user.
    Once submitted the create action will be hit.

    In create you then have to create a new user object containing the properties the user entered in the form. This happens through User.new(params[:user]) (where params[:user] is the data the user entered into the form) and then call .save on the object to persist it in the database.

    Here is how the create action code should ideally look like:

    def create
        @user = User.new(params[:user])
        if @user.save
    
          respond_to do |format|
            format.html # new.html.erb
            format.json { render json: @user }
          end
        else
          # validation failed
          respond_to do |format|
            format.html { render 'new' } #this will re-display the new form with model errors
            format.json { #give some error in the JSON }
          end
        end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that lets the user edit the content of the page
I have a dropdown on my master page that lets the user switch language
I have a simple page in a PHP/MySQL web application that lets admin users
I'm building a page admin in php and have a function that lets me
So I have a page setup that lets you expend text boxes upon click:
I have a page on my site that lets users respond to invites by
I have a 3rd party web page screen capture DLL from http://websitesscreenshot.com/ that lets
I have a same domain iframe within a page that lets users upload unlimited
I have a page that lets the viewer edit objects. The page displays a
Let's say you have a profile page that can only be accessed by 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.