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

  • Home
  • SEARCH
  • 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 7752897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:54:57+00:00 2026-06-01T11:54:57+00:00

To create a new user I use a search view to find user info

  • 0

To create a new user I use a search view to find user info in ldap and populate the data in the new user creation form. Then submitting that form will create a new user locally in mysql. So the new user create form is already populated and I can the values. But after submitting that form the page comes back with message saying the fields were blank. Not sure why is that. In http debug I see those values were posted to /users/new

Form is invalid

User can't be blank
Firstname can't be blank
Lastname can't be blank
Email can't be blank
Role can't be blank

Controller –

class UsersController < ApplicationController


  def new
        @user = User.new
        @result = User.FindActiveDirectory(params[:user_id])
    if @result.empty?
        render action: 'find', message: "Could not find a user with the id #{params[:user_id]}"
else
    return @result

    end

  end

def find
end


def display_result

    @result = User.FindActiveDirectory(params[:user_id])
    if @result.empty?
        render action: 'find', message: "Could not find a user with the id #{params[:user_id]}"
    end
return @result
end


  def create

        @user = User.new(params[:user_id])
        if @user.save
                redirect_to users_added_url, :notice => "Signed up!"
        else
                render "new"
        end
  end

end

User view find (find.html.erb) –

<h1>find User </h1>
<p><%= notice %></p>

<%= form_tag users_new_path do %>
  <p>
    <%= label_tag :Username %><br />
    <%= text_field_tag :user_id %>
  </p>
  <p class="button"><%= submit_tag " Search " %></p>
<% end %>

Users view create new (new.html.erb)-

<h1>Add user to access this system</h1>

<% if @result %>
<% @result.each do |key, values| %>
<% if "#{key}" == "samaccountname" %>
<% $username = values.to_s %>
<% end %>
<% if "#{key}" == "sn" %>
<% $lastname = values.to_s %>
<% end %>
<% if "#{key}" == "givenname" %>
<% $firstname = values.to_s %>
<% end %>
<% if "#{key}" == "mail" %>
<% $email = values.to_s %>
<% end %>
<% end %>
<% end %>


<%= form_for @user do |f| %>
  <% if @user.errors.any? %>
    <div class="error_messages">
      <h2>Form is invalid</h2>
      <ul>
        <% for message in @user.errors.full_messages %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>
 <p>
    <%= f.label :NT_Username %><br />
    <%= f.text_field :user_id, :value => $username  %>
  </p>
 <p>
    <%= f.label :Firstname %><br />
    <%= f.text_field :firstname, :value => $firstname  %>
  </p>
 <p>
    <%= f.label :Lastname %><br />
    <%= f.text_field :lastname, :value => $lastname %>
  </p>
  <p>
    <%= f.label :Email %><br />
    <%= f.text_field :email, :value => $email %>
  </p>
  <p>
    <%= f.label :Role %><br />
    <%= f.collection_select :role, User::ROLES, :to_s, :to_s, :include_blank => false %>
  </p>
  <p class="button"><%= f.submit %></p>
<% end %>

Request –

Started POST "/users" for 10.15.21.28 at 2012-04-07 00:00:17 -0400
Processing by UsersController#create as HTML
  Parameters: {"utf8"=>"â", "authenticity_token"=>"RDxvWXxVwoJArNN1s4Q8M8cDr5rzjP4wNF4gOnteGGY=", "user"=>{"user_id"=>"jkills000", "firstname"=>"James", "lastname"=>"Kills", "email"=>"jkills000@mysite.com", "role"=>"User"}, "commit"=>"Create User"}
  • 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-01T11:54:58+00:00Added an answer on June 1, 2026 at 11:54 am

    In your create you do:

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

    This is incorrect. It should be:

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

    As you can see in the request, params[:user] contains all the info about the user. params[:user_id] does not exist.

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

Sidebar

Related Questions

In a view I'm trying to create a new user and then log them
When the user presses the text Add, then I'd like to create a new
How can create a New user in ORACLE with full access (alter, delete, select,
I have a database called ADB. When I create a new user/role, that user
I am trying to create a page for new user sign where i am
def new @title = Create a user @user = User.new end <%= form_for(@user) do
I create a new page using HTMl and I whant when user clicks on
One of my web pages allows the user to create a new record, and,
I want to use an AutoCompleteTextView in my activity and populate the data as
I am trying to create a search function that allows the user to search

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.