how to show multiple errors

If these are errors from your models you can use error_messages_for(...)

<%= error_messages_for :user %>

Hope this helps.

I can't think of an example of when you'd have multiple errors when
not dealing with models. Are you sure you're not talking about errors
in saving, creating, or modifying ActiveRecord models? Give an
example of 10 errors.

I think the problem is that you’re assigning multiple errors to flash[:error] like this:

flash[:error] = “whatever”

and that will clobber all your old assignments. If this is the case, you can just do this at the beginning of your controller method:

flash[:error] = []

and then push error messages into the Array. You could use a hash if you wanted that functionality. There’s a couple of different ways to do that but the important thing is to remember that while flash is a hash, flash[:whatever] isn’t [unless you make it so].

Then again, this might not be the problem but since you didn’t post any code I’m having to assume it is.

RSL

I am still stuck on this problem. I will explain what I am trying to do:

On my form I have fields to creae a new user. For that I have a login
id, pwd1 and pwd2 and email fields alongwith other fields. Now if login
already exists, or two passwords don't match or email is not in a corret
in proper format, then I need to show all the error alongwith the values
entered by the user. I am able to show only the last error put in
flash[:error] as:

It sounds like you'd benefit from reviewing the basics of creating
models (a new user in this case) from forms. I highly recommend the
AWDWR book for this. But to get you jumpstarted you can use the
following code as an example:

<%= error_messages_for :user %>

<% form_tag :action => 'create' do %>
  Username: <%= text_field :user, :name %> </br>
  Password: <%= password_field :user, :password %> </br>
  Password: <%= password_field :user, :password_confirmation %> </br>
  Email: <%= text_field :user, :email_address %> </br>
  <%= submit_tag 'Create user' %>
<% end %>

flash[:error] = msg

All the error that I have put in before are not displayed in the view by
:
<% if flash[:error] -%>
<%= flash[:error]%>
<% flash[:error] = nil %>
<%else %>
&nbsp;
<% end -%>

Also how can I fill the form with the values entered by the user when
view is displayed again ? I am new to ruby and rails, hence this seems
like a big task for me. Any help is really appreciated.

In your controller's action:

  def create
    @user = User.create(params[:user])
     if @user.valid?
        flash[:success] = 'User created.'
        redirect_to :action => 'index'
      else
        render :action => 'new'
      end
  end

This will preserves the form values.

Hope this helps.