views:

74

answers:

1

Hello,

I'm using Rails 2.3.4/Ruby 1.9.1 for my application. In the view I have this to show error messages:

<%= content_tag('div', flash[:notice], :class => 'flash notice') if flash[:notice] %>

it works fine if I assign it manually from the controller such as:

flash[:notice] = "User Name can only contain letters, number - or _"

But for the automatic validation in the model such as:

  validates_uniqueness_of :user_name

the error messages don't show! although the form doesn't submit which what should happen but I don't see the error messages.

Any ideas?

Thanks,

Tam

+3  A: 

Unless this has changed very recently in rails, flash[:notice] is never populated by model validations. To display errors from a validation in the view, you would use the error_messages_for method.

Brad