Form not inserting data into database

I have a form to register a user. The issue I am having is the fact that
it only populates login, hashed_password and created_at fields.

DB table:
create table users (
id int not null auto_increment,
login varchar(100) default null,
hashed_password char(40) default null,
email varchar(255) default null,
salt varchar(255) default null,
address varchar(255) null,
city varchar(255) not null,
state varchar(255) not null,
country varchar(255) not null,
phone varchar(255) not null,
website varchar(255) not null,
created_at datetime null,
primary key (id)
);

users_controller:

Add a new user to the database.

def register_user
if request.get?
@user = User.new
else
@user = User.new(params[:user])
if @user.save
flash[:notice] = “User #{@user.login} created”
#redirect_to :action => ‘//login/login’
redirect_to :controller=>‘adverts’, :action=>‘list’#, :id =>
@user.id
end
end
end

register_user.rhtml:

Please Sign Up

The More information you provide the easier it will be for people to find you or your company. <%= start_form_tag :action => 'register_user' %> <%= render :partial => 'form' %> <%= submit_tag "Register" %> <%= end_form_tag %>

_form.rhtml:

<%= error_messages_for ‘user’ %>

Please help

User name or company name: <%= text_field("user", "login") %>
Password: <%= text_field("user", "password") %>
Email: <%= text_field("user", "email") %>
Address: <%= text_field("user", "address") %>
City: <%= text_field("user", "city") %>
State: <%= text_field("user", "state") %>

Hi David,

I think the problem is your password field in your form is not matched
with the field in the database, you should change hashed_password to
‘password’.

Hope it helpful.

Socheat

David S. wrote:

I have a form to register a user. The issue I am having is the fact that
it only populates login, hashed_password and created_at fields.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs