Sam Donaldson
2006-Oct-04 09:59 UTC
A better method for Rails validation error management.
Hi, I''ve been looking into several ways of doing user error management and display but I''m not sure if error_messages_for is the right way. The problem is that I end up writing a ton of ''if'' error_messages_for @obj in my layout template as I''d like to display error messages right below my header. Problem is that this isn''t that great as it relies on instance variable names defined in my actions. What if I want to change them later on? Also, every page that gets rendered will have to check this block in the layout to make sure none of the instance variablse have errors in them. Does anybody know of a much more cleaner and better way? Errors coming out of validation should get displayed under the header but I don''t want to have to run through all objects. This just doesn''t seem right for the non-error cases. Any help would be appreciated on a better way to do validation based error display along with internal exception based error management, Sam. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Gareth Adams
2006-Oct-04 10:22 UTC
Re: A better method for Rails validation error management.
Sam Donaldson <rails-mailing-list@...> writes:> Any help would be appreciated on a better way to do validation based > error display along with internal exception based error management, > > Sam.Take a look at http://api.rubyonrails.org/classes/ActiveRecord/Errors.html for all the things you can do with your @item.errors object Gareth --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---