Is there any way to control the ordering of the error messages in the output of error_messages_for()? I want to make the error messages match the order of the form elements in my form, and although the validates_presence_of directive has these attributes in that order, they still show up in seemingly random order. Any way to control this? Thanks, Wes -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 9 Mar 2009, at 15:07, Wes Gamble wrote:> > Is there any way to control the ordering of the error messages in the > output of error_messages_for()?At the end of the day the errors are stored in a hash and thus with no guarenteed order. This might be a good time to replace error_messages_for with code of your own (if you poke inside the source for it you''ll see that it''s pretty simple). Fred> > > I want to make the error messages match the order of the form elements > in my form, and although the validates_presence_of directive has these > attributes in that order, they still show up in seemingly random > order. > > Any way to control this? > > Thanks, > Wes > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
Fred, I already have a custom version of error_messages_for, so yeah, that''s cool. Thx. for the quick response. Wes -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Mar 9, 2009 at 10:07 AM, Wes Gamble <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Is there any way to control the ordering of the error messages in the > output of error_messages_for()? > > I want to make the error messages match the order of the form elements > in my form, and although the validates_presence_of directive has these > attributes in that order, they still show up in seemingly random order. > > Any way to control this?I put my error messages right under the fields they are for: <%= f.username :text_field %> <% if @user.errors[''username''] -%> <br /><span class="error"><%= @user.errors[''username''] %></span> <% end -%> I did not like error_messages_for() when I first tried and I''ve since found most of my clients don''t care for it either. -- Greg Donald http://destiney.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?hl=en -~----------~----~----~----~------~----~------~--~---
You can do this: <%= f.text_field :email, :label => "Email Address", :required => true %> <em><%= error_message_on @user, :email %></em> --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---