Validation error messages not being displayed

i cna’t figure out why my validation errors are not showing up when I
submit
my form with errors.

My new.rhtml view looks like:

<% unless @user.errors.empty? %>

Your comment could not be saved because:



    <% @user.errors.each_full do |msg| %>
  • <%= msg %>

  • <% end %>

<% end %>
Please choose a username and password to create your account
User Name*:
Password*:
Account Information
Company Name*:
First Name*:
Last Name*:
Email Address*:
Address 1*:
Address 2:
City*:
State: <% @mystates.each do |state| %> <%= state.statename %> <% end %>
Zip Code*:
Phone*:
Mobile*:

My Model looks like:

validates_length_of :username, :within =>6…12, :message=>“Username must
be at
least 10 characters”
validates_presence_of :username, :password, :company_name, :first_name,
:last_n
ame, :email, :address1, :address2, :city, :zip, :phone
validates_uniqueness_of :username

And my controller looks like:

class UserController < ApplicationController
ActiveRecord::Validations::ClassMethods
scaffold :user

def new
@user = User.new
@mystates = State.find_all
@user.errors
end

def create
@newuser = User.new(@params[‘user’])
@newuser.creation_date = Date.today
@newuser.last_login = Date.today
if @newuser.save
flash[:notice] = “Entry was successfully created”
redirect_to :action => “new”
else
render_action “new”
end
end

end

I also tried inserting “<%= error_messages_for ‘user’ %>” into my view,
but
that didn’t work either. What’s happening now is if i submit the form
with
an ‘errors’, the new view/template reappears without any errors. I want
it to
reappear with errors (and also preferably with the user’s info defaulted
so
that they don’t have to retype it in).
I’ve already spent two hours trying to get this to work :frowning: Any help will
be
much appreciated!