want to get one-by-one error message

Dear all,

In RoR, on one form if I 've applied validations to 7 fields & while running an application if user insert invalid values in i.e. 3 fields at that time RoR shows error message for all 3 fields.

I want error messages to be shown one-by-one....

Like if user correct first field then only he 'll get error for second field not before that.

Thanking you...

In RoR, on one form if I 've applied validations to 7 fields & while

running an application if user insert invalid values in i.e. 3 fields at

that time RoR shows error message for all 3 fields.

I want error messages to be shown one-by-one…

Like if user correct first field then only he 'll get error for second

field not before that.

That sounds worse for the user, they have to submit each time only to be told “hang on, there’s something else wrong - I knew about it before but you’re too stupid to be told more than one thing at a time”.

However, it’s your app…

I’d recommend using the @object.errors enumerator yourself rather than just relying on error_messages_for. For example:

error = @object.errors.first

if error

attr,msg = error

if attr != “base”

content_tag :div, “#{attr} #{msg}”, :class => “my_error”

else

content_tag :div, “#{msg}”, :class => “my_error”

end

end

You’d probably want to put this in a helper, but that’s the basics of what you want to do…

Hope that helps.

Cheers,

Andy

That sounds worse for the user, they have to submit each time only to be told "hang on, there's something else wrong - I knew about it before but you're too stupid to be told more than one thing at a time".

---------------------------------------------

dear Andy,

Thanks for your help... I too know it's stupidity to show one-by-one message

but while you work as developer you need to follow requirements given by client & that 's strictly professional in big industry...

Regards Rutvij

dear Andy,

Thanks for your help… I too know it’s stupidity to show one-by-one

message

but while you work as developer you need to follow requirements given by

client & that 's strictly professional in big industry…

I agree, I’ve had to do some daft things for a client (that I’m still working with) that have nearly caused me to be laughed out of IRC channels…

Hopefully the message also gave you ideas for a solution.

Cheers,

Andy